Make WordPress Core


Ignore:
Timestamp:
09/06/2013 10:06:40 PM (11 years ago)
Author:
wonderboymusic
Message:

Ensure that the post type object is the queried object when a post type has been registered with has_archive => true. Ensure it is not stomped when decorated with tax_query. Adds unit tests.

Props nacin.
Fixes #18614.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r25207 r25291  
    578578    }
    579579
     580    // If there's a post type archive
     581    if ( is_post_type_archive() ) {
     582        $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
     583        if ( ! $post_type_object->has_archive )
     584            $title = post_type_archive_title( '', false );
     585    }
     586
    580587    // If there's a category or tag
    581588    if ( is_category() || is_tag() ) {
     
    596603    }
    597604
    598     // If there's a post type archive
    599     if ( is_post_type_archive() )
     605    // Post type archives with has_archive should override terms.
     606    if ( is_post_type_archive() && $post_type_object->has_archive )
    600607        $title = post_type_archive_title( '', false );
    601608
     
    697704        return;
    698705
    699     $post_type_obj = get_queried_object();
     706    $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
    700707    $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
    701708
     
    16711678    $args = wp_parse_args( $args, $defaults );
    16721679
    1673     if ( is_single() || is_page() ) {
     1680    if ( is_singular() ) {
    16741681        $id = 0;
    16751682        $post = get_post( $id );
     
    16791686            $href = get_post_comments_feed_link( $post->ID );
    16801687        }
     1688    } elseif ( is_post_type_archive() ) {
     1689        $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
     1690        $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
     1691        $href = get_post_type_archive_feed_link( $post_type_obj->name );
    16811692    } elseif ( is_category() ) {
    16821693        $term = get_queried_object();
Note: See TracChangeset for help on using the changeset viewer.