Advertisements

single_term_title

Definition:
function single_term_title( $prefix = '', $display = true ) {}

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 wp_title(), because of its limited implementation.

Parameters

  • string $prefix: Optional. What to display before the title.
  • bool $display: Optional, default is true. Whether to display or retrieve title.

Return values

returns:Title when retrieving, null when displaying or failure.

Defined filters

  • single_cat_title
    apply_filters( 'single_cat_title', $term->name )
  • single_tag_title
    apply_filters( 'single_tag_title', $term->name )
  • single_term_title
    apply_filters( 'single_term_title', $term->name )

Source code

function single_term_title( $prefix = '', $display = true ) {

	$term = get_queried_object();



	if ( !$term )

		return;



	if ( is_category() )

		$term_name = apply_filters( 'single_cat_title', $term->name );

	elseif ( is_tag() )

		$term_name = apply_filters( 'single_tag_title', $term->name );

	elseif ( is_tax() )

		$term_name = apply_filters( 'single_term_title', $term->name );

	else

		return;



	if ( empty( $term_name ) )

		return;



	if ( $display )

		echo $prefix . $term_name;

	else

		return $term_name;

}

10301

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: