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

git-svn-id: https://develop.svn.wordpress.org/trunk@15819 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2010-10-15 19:44:57 +00:00
parent 227e02298a
commit 38092bb128
5 changed files with 148 additions and 8 deletions
+30 -1
View File
@@ -547,6 +547,10 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
$title = $author->display_name;
}
// If there's a post type archive
if ( is_post_type_archive() )
$title = post_type_archive_title( '', false );
// If there's a month
if ( is_archive() && !empty($m) ) {
$my_year = substr($m, 0, 4);
@@ -611,7 +615,6 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
* be a space, the parameter value will need to have it at the end.
*
* @since 0.71
* @uses $wpdb
*
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional, default is true. Whether to display or retrieve title.
@@ -635,6 +638,32 @@ function single_post_title($prefix = '', $display = true) {
return $title;
}
/**
* Display or retrieve title for a post type archive.
*
* This is optimized for archive.php and archive-{$post_type}.php template files
* for displaying the title of the post type.
*
* @since 3.1.0
*
* @param string $prefix Optional. What to display before the title.
* @param bool $display Optional, default is true. Whether to display or retrieve title.
* @return string|null Title when retrieving, null when displaying or failure.
*/
function post_type_archive_title() {
if ( ! is_post_type_archive() )
return;
$post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
if ( $display )
echo $prefix . $title;
else
return $title;
}
/**
* Display or retrieve page title for category archive.
*