WordPress tip: Conditional tag for blog-related pages

Copy the function below and paste it into your functions.php file:

 function is_blog() { 	if (is_home() || is_singular('post') || is_post_type_archive('post')) 		return true; 	else return false; }

Once done, you can use the function to detect if you’re currently on a blog related page:

 <?php if(is_blog()) {     //the page is blog related } ?>

Thanks to Nathan for the tip!


WpRecipes.com

Web Design

blogrelatedConditionalPagesWordPress

Leave a Reply

Your email address will not be published. Required fields are marked *