#51042 closed defect (bug) (fixed)
Post missing excerpt
| Reported by: | riaanlom | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.5.1 |
| Component: | Posts, Post Types | Version: | 5.5 |
| Severity: | normal | Keywords: | commit fixed-major |
| Cc: | Focuses: |
Description
If post doesn't have an excerpt, expected outcome is for it to be generated from the post content.
wp-includes/formatting.php
function wp_trim_excerpt line 3811
if ( '' === $text )
Previous versions of WP used == instead of === . The strict comparison operator returns an empty excerpt
Change History (8)
#2
follow-up:
↓ 3
@
6 years ago
@laxman-prajapati
I'm not calling the function directly.
This used to return the generate excerpt from the post content but with WP 5.5 it returns NULL
$post = get_post(1); $excerpt = ! empty( $post->post_excerpt ) ? $post->post_excerpt : null; $excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );
#3
in reply to: ↑ 2
@
6 years ago
@riaanlom
Ok, I have one minor change.
Can you please try with below?
$post = get_post(1); $excerpt = ! empty( $post->post_content ) ? $post->post_excerpt : null; $excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );
Hope It will works for you.
Thanks,
Laxman P
Replying to riaanlom:
@laxman-prajapati
I'm not calling the function directly.
This used to return the generate excerpt from the post content but with WP 5.5 it returns NULL
$post = get_post(1); $excerpt = ! empty( $post->post_excerpt ) ? $post->post_excerpt : null; $excerpt = apply_filters( 'get_the_excerpt', $excerpt, $post );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@riaanlom
Yes, I agree the == instead of === condition changed on the WordPress version 5.5
But are using like this?: https://developer.wordpress.org/reference/functions/wp_trim_excerpt/
Can you please review this one, May be it will help you.
Thanks,
Laxman P.