Make WordPress Core


Ignore:
Timestamp:
10/15/2010 07:44:57 PM (16 years ago)
Author:
nacin
Message:

Custom post type archives, second pass. see #13818.

File:
1 edited

Legend:

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

    r15771 r15819  
    548548        }
    549549
     550        // If there's a post type archive
     551        if ( is_post_type_archive() )
     552                $title = post_type_archive_title( '', false );
     553
    550554        // If there's a month
    551555        if ( is_archive() && !empty($m) ) {
     
    612616 *
    613617 * @since 0.71
    614  * @uses $wpdb
    615618 *
    616619 * @param string $prefix Optional. What to display before the title.
     
    636639}
    637640
     641/**
     642 * Display or retrieve title for a post type archive.
     643 *
     644 * This is optimized for archive.php and archive-{$post_type}.php template files
     645 * for displaying the title of the post type.
     646 *
     647 * @since 3.1.0
     648 *
     649 * @param string $prefix Optional. What to display before the title.
     650 * @param bool $display Optional, default is true. Whether to display or retrieve title.
     651 * @return string|null Title when retrieving, null when displaying or failure.
     652 */
     653function post_type_archive_title() {
     654        if ( ! is_post_type_archive() )
     655                return;
     656
     657       
     658        $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
     659        $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
     660
     661        if ( $display )
     662                echo $prefix . $title;
     663        else
     664                return $title;
     665}
     666       
    638667/**
    639668 * Display or retrieve page title for category archive.
Note: See TracChangeset for help on using the changeset viewer.