Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.