• I am trying to create a new header in between two differtent sections that both use the single.php template. I was hoping i could target by using the body class bu t i have been unable to do that.

    any idea how i can get them to differentiate??

    <?php
    // the page or parent page of "blog"
    if ( is_single()  ) { 
    
       echo '<div id="callout" class="join">
            	<h3>News</h3>
           		<p>Review the navigation below to find this sections pages.</p>
          		</div>';
    
       echo '<div id="pic"><img src="/wp-content/themes/treadlightly/images/hdr-news.jpg" alt="News"></div>';
    
       // the page or parent page of "Shop"
    } elseif ( is_page( '197' ) || '197' == $post->post_parent || is_page( 'single' ) ) { 
    
       echo '<div id="callout" class="shop">
            	<h3>Shop</h3>
           		<p>Review the navigation below to find this sections pages.</p>
          		</div>';
    
       echo '<div id="pic"><img src="/wp-content/themes/treadlightly/images/hdr-shop.jpg" alt="Shop"></div>';
    
    } else {
        // the page is "Backup", or the parent of the page is "Backup"
    
       echo '<div id="callout" class="join">
            	<h3>Tread Lightly</h3>
           		<p>Review the navigation below to find this sections pages.</p>
          		</div>';
    
       echo '<div id="pic"><img src="/wp-content/themes/treadlightly/images/hdr-backup.jpg" alt="Tread Lightly"></div>';
    }	
    
    ?>

    Thank you!

  • The topic ‘conditional statement for single.php targeting body class?’ is closed to new replies.