Conditional Template Classes in WordPress

For singe post vs feed:

<header class="entry-header 
  <?php 
    if ( is_single() ) : 
      echo 'container'; 
    endif; 
  ?>
">
</header>

For context, this code would be inside of

📁 theme > 📁 template parts > 📄 content.php

Where 📄 content.php is being called within multiple templates:

📄 index.php
📄 single.php

The 📄 content.php conditionally displays content based on what template it is being displayed inside of.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments