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?
1 Answer
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 );
-
1