WordPress.org

Support

Support » How-To and Troubleshooting » pages plus subpages conditional tag

pages plus subpages conditional tag

  • Hi, I created various template_parts which are recalled by page name.
    The code is like this:

    <?php get_template_part( $slug, $name );
    if ( is_page( 'page_one' ) ) :
    	get_template_part( 'media-page_one' );
    elseif ( is_page( 'page_two' ) ) :
    	get_template_part( 'media-page_two' );
    else :
      get_template_part('');
    endif
    ?>

    How can I change this code so even the child pages get included?
    I tried:

    if ( is_page( 'page_one' ) || 'page_one' == $parent_name ) :
    	get_template_part( 'media-page_one' );

    …bur it doesn’t work. What am I missing?

    thanks for any hint

    Alby

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘pages plus subpages conditional tag’ is closed to new replies.