Created
August 17, 2012 17:52
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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