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);
  • 2
    was the function formerly named set_default_page_template, then you changed it to set_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. Jul 26, 2018 at 19:24
  • Thank you, for some reason it was looking for both set_page_default_template and set_default_page_template. I just made an empty function for the opposite that wont be called.
    – Tyler
    Jul 26, 2018 at 19:42

1 Answer 1


You get an error because it's looking for function named as set_default_page_template while you seems to have function named set_page_template_default.

I'm not sure you either don't have a function named set_default_page_template or you later renamed it. but that's the error. WP cannot find your hook because it doesn't exist.

you should either rename your set_default_page_template to set_default_page_template (if this is the function what you need) or you should create a new function and name it as set_default_page_template

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.