Created
August 28, 2014 22:15
-
-
Save fitzhaile/4cf4aedbb219761c2228 to your computer and use it in GitHub Desktop.
An is_blog() conditional function for Wordpress.
This file contains hidden or 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 | |
/** | |
* An is_blog() conditional function for Wordpress. | |
* | |
* Determines if the current page is blog(y), including: | |
* | |
* - Posts page | |
* - Archive (category, tag, author) | |
* - Single post | |
* - Custom page template that may be displaying blog like content (like a custom archive page) | |
* | |
* @return bool | |
*/ | |
function is_blog( $templates = array() ) { | |
global $post; | |
$post_type = get_post_type($post); | |
return ( | |
in_array( true, array_map( 'is_page_template', $templates ) ) || | |
( is_home() || is_archive() || is_single() ) && ( $post_type == 'post' || ! $post_type ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment