single_post_title

Advertisement

Summery Summery

Display or retrieve page title for post.

Syntax Syntax

single_post_title( string $prefix = '', bool $display = true )

Description Description

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.

Parameters Parameters

$prefix

(Optional) What to display before the title.

Default value: ''

$display

(Optional) Whether to display or retrieve title.

Default value: true

Return Return

(string|void) Title when retrieving.

Source Source

File: wp-includes/general-template.php

	}

	// Post type archives with has_archive should override terms.
	if ( is_post_type_archive() && $post_type_object->has_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 ) ) {

Advertisement

Changelog Changelog

Changelog
Version Description
0.71 Introduced.

Advertisement

Leave a Reply