How To Display A Snippet of Code Only on the Main Page And Certain Pages

The following code is in case you need to display a snippet of code only on the main page and certain pages of your blog.

<?php wp_reset_query(); ?>
<?php if(is_home() || is_front_page() || is_page( 12) || is_page( 150)): ?>
     Put your code in here...
<?php else: ?>
     Put another code in here...
<?php endif;  ?>

Read the complete WP Conditional Tags here.

 

Leave a Reply

Your email address will not be published.