Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/wp-includes/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,24 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
return $output;
}

/**
* Determines whether a post has content.
*
* @since 7.1.0
*
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to the global post.
* @return bool Whether the post has content.
*/
function has_content( $post = null ) {
$post = get_post( $post );

if ( ! $post instanceof WP_Post ) {
return false;
}

return '' !== trim( $post->post_content );
}

/**
* Displays the post excerpt.
*
Expand Down
Loading