I was able to successfully set the default page template for a new page, when there is not yet a defined template to be member_home_page.php.
This works perfectly on my local environment but when I uploaded the code to my site on WP Engine I get this error at the top of the admin page edit screen for WordPress.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'set_default_page_template' not found or invalid function name in /nas/content/staging/pmbus/wp-includes/class-wp-hook.php on line 288
Both on local and live deployments the function works. But on local I don't get the error, only live. Below is the function, i'm just not sure why i'm getting this warning only on live. Thanks in advance.
function set_page_template_default() {
global $post;
if ( 'page' == $post->post_type
&& 0 != count( get_page_templates( $post ) )
&& get_option( 'page_for_posts' ) != $post->ID // Not the page for listing posts
&& '' == $post->page_template // Only when page_template is not set
) {
$post->page_template = 'member_home_page.php';
}
}
add_action('add_meta_boxes', 'set_page_template_default', 1);
set_default_page_template
, then you changed it toset_page_template_default
? I'm guessing here: but if thats the case, WPEngine is likely showing you a cache of the old error. These 'dedicated WP hosts' have really good cache's, ensure they're off while developing for less headaches.