[wp-trac] [WordPress Trac] #46983: get_the_excerpt() PHP warning if no except/post_content exists.
WordPress Trac
noreply at wordpress.org
Thu Apr 18 19:08:53 UTC 2019
#46983: get_the_excerpt() PHP warning if no except/post_content exists.
--------------------------+-----------------------------
Reporter: jaredatch | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.1.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In blog post single templates, it's not uncommon to have a blog "header"
that pulls from whatever is set in the page_for_posts option. Example:
https://cl.ly/2d27f2540fdc
This can be accomplished in the single post template by checking.
{{{
$title = get_the_title( get_option( 'page_for_posts' ) );
$desc = get_the_excerpt( get_option( 'page_for_posts' ) );
}}}
However if the Blog page does not have anything inside the excerpt OR the
post content, it triggers a PHP error.
See https://cl.ly/7dc933f2ef76
If there is no post content or excerpt, the function should return an
empty string.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46983>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list