single_month_title

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

Display or retrieve page title for post archive based on date.
Useful for when the template only needs to display the month and year, if either are available. Optimized for just this purpose, so if it is all that is needed, should be better than wp_title().

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.

Source code

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

	global $wp_locale;



	$m = get_query_var('m');

	$year = get_query_var('year');

	$monthnum = get_query_var('monthnum');



	if ( !empty($monthnum) && !empty($year) ) {

		$my_year = $year;

		$my_month = $wp_locale->get_month($monthnum);

	} elseif ( !empty($m) ) {

		$my_year = substr($m, 0, 4);

		$my_month = $wp_locale->get_month(substr($m, 4, 2));

	}



	if ( empty($my_month) )

		return false;



	$result = $prefix . $my_month . $prefix . $my_year;



	if ( !$display )

		return $result;

	echo $result;

}

2889

single_cat_title

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

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 wp_title().

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.

Source code

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

	return single_term_title( $prefix, $display );

}

2887