WordPress.org

Ready to get started?Download WordPress

Forums

conditional statement for single.php targeting body class? (1 post)

  1. kmaier
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.