Skip to content

Instantly share code, notes, and snippets.

@timstl
Last active March 31, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timstl/c3320081593e080bb596240279647061 to your computer and use it in GitHub Desktop.
Save timstl/c3320081593e080bb596240279647061 to your computer and use it in GitHub Desktop.
Determine if currently viewing a WordPress blog page (home, archive, search, single post).
<?php
function is_blog_page($single=true, $four04=true) {
if ((is_home() || is_archive() || is_search()) && !is_post_type_archive()) {
return true;
}
if ($single === true && is_singular('post')) {
return true;
}
if ($four04 === true && is_404()) {
return true;
}
return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment