Skip to content

Instantly share code, notes, and snippets.

@gfargo
Forked from wesbos/is_blog.php
Last active December 19, 2015 12:48
Show Gist options
  • Save gfargo/5957252 to your computer and use it in GitHub Desktop.
Save gfargo/5957252 to your computer and use it in GitHub Desktop.
Returns 'True' when the user is on a Wordpress 'Blog' page.
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@gfargo
Copy link
Author

gfargo commented Aug 3, 2015

Simple Wordpress Helper Function - checks if user is currently viewing a blog page 📰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment