0

I used the following code to apply a page template to my custom post (with all files in the plugin).

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' ) {
        add_post_meta($post->ID, '_wp_page_template', 'admin/single-simulators.php');;
     }

     return $single;
}

Everything seems to be flowing ... until ... I changed some ACF field in the post ... immediately the page template changed to default (So for every post that changed), what is the reason?

editing: I notice it's not related to a change in the post, even just saving the save button again, and the post will open in the default page template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.