Template page changes after ACF field change

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?

Read more here:: Template page changes after ACF field change

Leave a Reply

Your email address will not be published. Required fields are marked *