להכריח עמוד CPT להשתמש בתבנית עמוד משלי

force cpt page to use custom page template

//  This hooks into the page template and over rides the default template use this to make sure your magazine template is always default
add_filter( 'template_include', 'default_page_template', 99 );

function default_page_template( $template ) {
// Change page to post if not a page your working on or custom post type name
    global $post;
	if ( 'awards' == $post->post_type ){
            // change the default-page-template.php to your template name
    $default_template = locate_template( array( 'page-awards.php' ) );
        if ( '' != $default_template ) {
            return $default_template ;
        }
    }
    return $template;
}

מקור

https://wordpress.stackexchange.com/questions/260372/how-can-i-force-custom-post-type-to-use-a-specific-template

כתיבת תגובה