• I’m having trouble with adding some default text to my the_content field. I’m trying to set it up so I can have unique default text for each of my page templates.

    When I place the following code in my functions.php file, and then add a new page, no matter which of my page templates I choose, the page editor field for the_content displays “this must be page.php”

    Any ideas? (Thanks!)

    <?php
    add_filter( 'default_content', 'boilerplate' );
    
    function boilerplate ( $content ) {
    if ( is_page_template( 'front-page.php' )): {
         $content = 'this  is front-page.php';
         }
    elseif ( is_page_template( 'leftmenu-page.php' )): {
         $content = 'this  is leftmenu-page.php';
         }
    elseif ( is_page_template( 'notice-page.php' )): {
         $content = 'this  is notice-page.php';
         }
    else: {
         $content = 'this must be page.php';
    }
    endif;
        return $content;
    }
    ?>
  • The topic ‘If statement to check for page template not working’ is closed to new replies.