Make WordPress Core


Ignore:
Timestamp:
10/14/2010 10:39:47 AM (15 years ago)
Author:
nacin
Message:

Custom post type archives. see #13818.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r15795 r15803  
    103103 * Month, Year, Category, Author, ...
    104104 *
     105 * If the $post_types parameter is specified, this function will additionally
     106 * check if the query is for exactly one of the post types specified. If a plugin
     107 * is causing multiple post types to appear in the query, specifying a post type
     108 * will cause this check to return false.
     109 *
    105110 * @see WP_Query::is_archive()
    106111 * @since 1.5.0
    107112 * @uses $wp_query
    108113 *
     114 * @param mixed $post_types Optional. Post type or array of post types
    109115 * @return bool
    110116 */
    111 function is_archive() {
    112     global $wp_query;
    113 
    114     return $wp_query->is_archive();
     117function is_archive( $post_types = '' ) {
     118    global $wp_query;
     119
     120    return $wp_query->is_archive( $post_types );
    115121}
    116122
     
    12981304            }
    12991305
    1300             if ( '' != $qv['author_name'] ) {
     1306            if ( '' != $qv['author_name'] )
    13011307                $this->is_author = true;
    1302             }
    1303 
    1304             if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) )
     1308
     1309            if ( !empty( $qv['post_type'] ) )
     1310                $this->is_archive = true;
     1311
     1312            if ( $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax )
    13051313                $this->is_archive = true;
    13061314        }
     
    26062614     * Month, Year, Category, Author, ...
    26072615     *
     2616     * If the $post_types parameter is specified, this function will additionally
     2617     * check if the query is for exactly one of the post types specified. If a plugin
     2618     * is causing multiple post types to appear in the query, specifying a post type
     2619     * will cause this check to return false.
     2620     *
    26082621     * @since 3.1.0
    26092622     *
     2623     * @param mixed $post_types Optional. Post type or array of post types
    26102624     * @return bool
    26112625     */
    2612     function is_archive() {
    2613         return (bool) $this->is_archive;
     2626    function is_archive( $post_types ) {
     2627        if ( empty( $post_types ) || !$this->is_archive )
     2628            return (bool) $this->is_archive;
     2629
     2630        if ( ! isset( $this->posts[0] ) )
     2631            return false;
     2632
     2633        $post = $this->posts[0];
     2634
     2635        return in_array( $post->post_type, (array) $post_types );
    26142636    }
    26152637
     
    30033025    function is_singular( $post_types = '' ) {
    30043026        if ( empty( $post_types ) || !$this->is_singular )
    3005             return $this->is_singular;
     3027            return (bool) $this->is_singular;
    30063028
    30073029        $post_obj = $this->get_queried_object();
Note: See TracChangeset for help on using the changeset viewer.