_draft_or_post_title() – Get the post title.

You appear to be a bot. Output may be restricted

Description

Gets the post title.

The post title is fetched and if it is blank then a default string is returned.

Usage

$string = _draft_or_post_title( $post );

Parameters

$post
( int|WP_Post ) optional – Optional. Post ID or WP_Post object. Default is global $post.

Returns

string The post title if set.

Source

File name: wordpress/wp-admin/includes/template.php
Lines:

1 to 7 of 7
function _draft_or_post_title( $post = 0 ) {
  $title = get_the_title( $post );
  if ( empty( $title ) ) {
    $title = __( '(no title)' );
  }
  return esc_html( $title );
}
 

 View on GitHub View on Trac