Set a template on a custom post in the plugin

admin2025-04-21  0

I looked at some answers and didn't help

I'm trying the next section (right away) but it returns the template if errors in WordPress's built-in function lines. Like get_header ()

add_filter('template_include', 'my_custom_template');

function my_custom_template($single) {

global $post;

/* Checks for single template by post type */
if ( $post->post_type == 'simulators' ) {
        return SIMULATOR_URI . 'inc/themes/admin/single-simulators.php';
    }

return $single;

}

Basically, the template is already listed in WordPress templates, is there an easy way to set it as a custom post template?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745176922a288966.html

最新回复(0)