Opened 7 weeks ago
Last modified 6 weeks ago
#65511 new feature request
Introduce has_content() helper function
| Reported by: | salmanshafiq8630 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Posts, Post Types | Version: | 7.0 |
| Severity: | normal | Keywords: | 2nd-opinion has-patch |
| Cc: | Focuses: |
Description (last modified by )
Currently, there is no dedicated helper function for determining whether a post contains content.
Developers typically check the post_content property directly:
<?php $post = get_post( $post ); if ( $post && '' !== trim( $post->post_content ) ) { // The post has content. }
This proposal introduces a new has_content() helper function, similar to has_excerpt(), that provides a consistent API for checking whether a post contains non-empty content.
The function would:
- Accept a post ID, WP_Post object, or null.
- Return true if the post contains non-empty content after trimming whitespace.
- Return false if the post does not exist or its content is empty.
Change History (2)
This ticket was mentioned in PR #12262 on WordPress/wordpress-develop by @salmanshafiq8630.
7 weeks ago
#1
- Keywords has-patch added
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
https://core.trac.wordpress.org/ticket/65511