Skip to content

Instantly share code, notes, and snippets.

@grantnorwood
Created August 17, 2012 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grantnorwood/3381004 to your computer and use it in GitHub Desktop.
Save grantnorwood/3381004 to your computer and use it in GitHub Desktop.
WordPress' missing is_blog_page() 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.
<?php
/**
* WordPress' missing is_blog_page() 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.
*
* @see http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/query.php#L1572
*
* @return bool
*/
function is_blog_page() {
global $post;
//Post type must be 'post'.
$post_type = get_post_type($post);
//Check all blog-related conditional tags, as well as the current post type,
//to determine if we're viewing a blog page.
return (
( is_home() || is_archive() || is_single() )
&& ($post_type == 'post')
) ? true : false ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment