WordPress.org

Make WordPress Core

Ticket #21620: 21620.patch

File 21620.patch, 1.2 KB (added by grantnorwood, 9 years ago)

Patch containing new function.

  • wp-includes/query.php

     
    452452}
    453453
    454454/**
     455 * Determines if the currently viewed page is one of the blog pages, including the blog home page,
     456 * archive, category/tag, author, or single post pages.
     457 *
     458 * This is different than is_home(), because it doesn't just determine if the blog home page is
     459 * currently being viewed, but also uses is_home().
     460 *
     461 * @uses is_home()
     462 * @uses is_archive()
     463 * @uses is_single()
     464 * @uses $post
     465 *
     466 * @return bool True if the current page is any of the blog-related pages.
     467 */
     468function is_blog_page() {
     469   
     470    global $post;
     471   
     472    //Post type must be 'post'.
     473    $post_type = get_post_type( $post );
     474   
     475    //Check all blog-related conditional tags, as well as the current post type,
     476    //to determine if we're viewing a blog page.
     477    return (
     478        ( is_home() || is_archive() || is_single() )
     479        && ( $post_type == 'post' )
     480    ) ? true : false ;
     481   
     482}
     483
     484/**
    455485 * Is the query for a month archive?
    456486 *
    457487 * @see WP_Query::is_month()