function single_post_title($prefix = '', $display = true) {}

Display or retrieve page title for post.
This is optimized for single.php template file for displaying the post title.


  • 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_post_title
    apply_filters('single_post_title', $_post->post_title, $_post)

Source code

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

	$_post = get_queried_object();

	if ( !isset($_post->post_title) )


	$title = apply_filters('single_post_title', $_post->post_title, $_post);

	if ( $display )

		echo $prefix . $title;


		return $title;



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: Logo

You are commenting using your 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 )

Connecting to %s

%d bloggers like this: