Skip to content

Instantly share code, notes, and snippets.

@fitzhaile
Created August 28, 2014 22:15
Show Gist options
  • Save fitzhaile/4cf4aedbb219761c2228 to your computer and use it in GitHub Desktop.
Save fitzhaile/4cf4aedbb219761c2228 to your computer and use it in GitHub Desktop.
An is_blog() conditional function for Wordpress.
<?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