}
// 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);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
$my_day = intval(substr($m, 6, 2));
$title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
}
// If there's a year
if ( is_archive() && !empty($year) ) {
$title = $year;
if ( !empty($monthnum) )
$title .= $t_sep . $wp_locale->get_month($monthnum);
if ( !empty($day) )
$title .= $t_sep . zeroise($day, 2);
}
// If it's a search
if ( is_search() ) {
/* translators: 1: separator, 2: search phrase */
$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
}
// If it's a 404 page
if ( is_404() ) {
$title = __('Page not found');
}
$prefix = '';
if ( !empty($title) )
$prefix = " $sep ";
// Determines position of the separator and direction of the breadcrumb
if ( 'right' == $seplocation ) { // sep on right, so reverse the order
$title_array = explode( $t_sep, $title );
$title_array = array_reverse( $title_array );
$title = implode( " $sep ", $title_array ) . $prefix;
} else {
$title_array = explode( $t_sep, $title );
$title = $prefix . implode( " $sep ", $title_array );
}
$title = apply_filters('wp_title', $title, $sep, $seplocation);
// Send it out
if ( $display )
echo $title;
else
return $title;
}
/**
* Display or retrieve page title for post.
*
* This is optimized for single.php template file for displaying the post title.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 0.71
*
* @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 single_post_title($prefix = '', $display = true) {
$_post = get_queried_object();
if ( !isset($_post->post_title) )
return;
$title = apply_filters('single_post_title', $_post->post_title, $_post);
if ( $display )
echo $prefix . $title;
else
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( $prefix = '', $display = true ) {
if ( ! is_post_type_archive() )
return;
$post_type_obj = get_queried_object();
$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.
*
* This is useful for category template file or files, because it is optimized
* for category page title and with less overhead than {@link wp_title()}.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 0.71
*
* @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 single_cat_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
}
/**
* Display or retrieve page title for tag post archive.
*
* Useful for tag template files for displaying the tag page title. It has less
* overhead than {@link wp_title()}, because of its limited implementation.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 2.3.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 single_tag_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
}
/**
* Display or retrieve page title for taxonomy term archive.
*
* Useful for taxonomy term template files for displaying the taxonomy term page title.
* It has less overhead than {@link wp_title()}, because of its limited implementation.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @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 single_term_title( $prefix = '', $display = true ) {
$term = get_queried_object();
// 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);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
$my_day = intval(substr($m, 6, 2));
$title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
}
// If there's a year
if ( is_archive() && !empty($year) ) {
$title = $year;
if ( !empty($monthnum) )
$title .= $t_sep . $wp_locale->get_month($monthnum);
if ( !empty($day) )
$title .= $t_sep . zeroise($day, 2);
}
// If it's a search
if ( is_search() ) {
/* translators: 1: separator, 2: search phrase */
$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
}
// If it's a 404 page
if ( is_404() ) {
$title = __('Page not found');
}
$prefix = '';
if ( !empty($title) )
$prefix = " $sep ";
// Determines position of the separator and direction of the breadcrumb
if ( 'right' == $seplocation ) { // sep on right, so reverse the order
$title_array = explode( $t_sep, $title );
$title_array = array_reverse( $title_array );
$title = implode( " $sep ", $title_array ) . $prefix;
} else {
$title_array = explode( $t_sep, $title );
$title = $prefix . implode( " $sep ", $title_array );
}
$title = apply_filters('wp_title', $title, $sep, $seplocation);
// Send it out
if ( $display )
echo $title;
else
return $title;
}
/**
* Display or retrieve page title for post.
*
* This is optimized for single.php template file for displaying the post title.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 0.71
*
* @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 single_post_title($prefix = '', $display = true) {
$_post = get_queried_object();
if ( !isset($_post->post_title) )
return;
$title = apply_filters('single_post_title', $_post->post_title, $_post);
if ( $display )
echo $prefix . $title;
else
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( $prefix = '', $display = true ) {
if ( ! is_post_type_archive() )
return;
$post_type_obj = get_queried_object();
$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.
*
* This is useful for category template file or files, because it is optimized
* for category page title and with less overhead than {@link wp_title()}.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 0.71
*
* @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 single_cat_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
}
/**
* Display or retrieve page title for tag post archive.
*
* Useful for tag template files for displaying the tag page title. It has less
* overhead than {@link wp_title()}, because of its limited implementation.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @since 2.3.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 single_tag_title( $prefix = '', $display = true ) {
return single_term_title( $prefix, $display );
}
/**
* Display or retrieve page title for taxonomy term archive.
*
* Useful for taxonomy term template files for displaying the taxonomy term page title.
* It has less overhead than {@link wp_title()}, because of its limited implementation.
*
* It does not support placing the separator after the title, but by leaving the
* prefix parameter empty, you can set the title separator manually. The prefix
* does not automatically place a space between the prefix, so if there should
* be a space, the parameter value will need to have it at the end.
*
* @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 single_term_title( $prefix = '', $display = true ) {
$term = get_queried_object();