Skip to content

Instantly share code, notes, and snippets.

@jjeaton
Forked from wesbos/is_blog.php
Last active December 18, 2015 15:59
Show Gist options
  • Select an option

  • Save jjeaton/5808697 to your computer and use it in GitHub Desktop.

Select an option

Save jjeaton/5808697 to your computer and use it in GitHub Desktop.
WordPress' missing is_blog() function. Determines if the currently viewed page is one of the blog pages, including the blog home page, archive, category/tag, author, or single post pages.
function is_blog () {
if ( (is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag()) ) {
return true;
}
else {
return false;
}
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment