Advertisements

get_the_title

Definition:
function get_the_title( $id = 0 ) {}

Retrieve post title.
If the post is protected and the visitor is not an admin, then "Protected" will be displayed before the post title. If the post is private, then "Private" will be located before the post title.

Parameters

  • int $id: Optional. Post ID.

Defined filters

  • protected_title_format
    apply_filters('protected_title_format', __('Protected: %s')
  • private_title_format
    apply_filters('private_title_format', __('Private: %s')
  • the_title
    apply_filters( 'the_title', $title, $id )

Source code

function get_the_title( $id = 0 ) {

	$post = &get_post($id);



	$title = isset($post->post_title) ? $post->post_title : '';

	$id = isset($post->ID) ? $post->ID : (int) $id;



	if ( !is_admin() ) {

		if ( !empty($post->post_password) ) {

			$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));

			$title = sprintf($protected_title_format, $title);

		} else if ( isset($post->post_status) && 'private' == $post->post_status ) {

			$private_title_format = apply_filters('private_title_format', __('Private: %s'));

			$title = sprintf($private_title_format, $title);

		}

	}

	return apply_filters( 'the_title', $title, $id );

}

1859

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 )

Google+ photo

You are commenting using your Google+ 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: