_draft_or_post_title()
Gets the post title.
The post title is fetched and if it is blank then a default string is returned.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
String
. The post title if set.
Usage
_draft_or_post_title( $post );
- $post(int|WP_Post)
- Post ID or WP_Post object.
Default: global $post
Changelog
Since 2.7.0 | Introduced. |
_draft_or_post_title() draft or post title code WP 6.8
function _draft_or_post_title( $post = 0 ) { $title = get_the_title( $post ); if ( empty( $title ) ) { $title = __( '(no title)' ); } return esc_html( $title ); }