Created
September 26, 2014 17:36
-
-
Save generatepress/6c34867033af757b71b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fix page template issue causing metaboxes not to save | |
*/ | |
add_action('admin_init','generate_update_page_template_issue'); | |
function generate_update_page_template_issue() | |
{ | |
global $post; | |
$args = array( | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'post_type' => 'page' | |
); | |
$posts = get_posts($args); | |
foreach ( $posts as $post ) { | |
$page_template = $post->page_template; | |
if( !locate_template($page_template) ) : | |
update_post_meta($post->ID, '_wp_page_template', 'default'); | |
endif; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment