I use a static page (Blog) to display the latest posts. I want to show the excerpt of that page next to the title. However, wen I use wp_kses_post( get_the_excerpt() ), I get the excerpt of the latest post from the post archive loop. I also tried with wp_kses_post( get_the_archive_description() ) but it also does not seem to work.. Any idea how this can be done?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can use get_queried_object() to get the static page data, and then do something like so to get the excerpt of the page:
echo get_the_excerpt( get_queried_object() );
// Or to apply filters just as the_excerpt() does:
$excerpt = get_the_excerpt( get_queried_object() );
echo apply_filters( 'the_excerpt', $excerpt );
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0