Excerpt of Custom Post Type Episode

Hi,

on our website we use Podlove with Elementor and the “Elementor Hello” theme.
Elementor has a module to display a list of posts as teasers and add things like an excerpt.

With every other post type, Elementor knows how to display the excerpt with the correct length.

However, if i choose the “episode” post type of Podlove it just shows the entire text of the episode in the excerpt. It doesn’t cut it of.

Here’s an example with the post list where the first post is of a podlove episode post type and the second a regular worpress post.
image

See the problem? For the regular post the length of the excerpt is as defined in the setting of Elementor. But the podlove episode post type just lists the entire thing as an excerpt.

Is there something with podlove that it doesn’t register it’s excerpts with Wordpress or something like that? Sorry, i’m no developer, so i hope someone in this forum can help.

I found the problem:

Podlove generates it’s own “excerpt” when you fill out the “Zusammenfassung” field in the post backend. Elementor cannot shorten manual excerpts.

I now just need to find a workaround.

Someone at the Elementor Git issue postet a nice workaround that does the trick for now:

Put this code into the functions.php :

 function summary($content, $limit = 200) {
   $content = strip_tags($content);
   // Take the existing content and return a subset of it
   $end = '';
   if (strlen($content) > $limit) {
       $end = '...';
   }
   return substr($content, 0, $limit) . $end;
} 
   
add_action( 'elementor_pro/posts/query/custom_excerpt', function( $query ) {
   
    function trimTitle( $text, $id = null ) {
       return summary($text,80);
}

function trimExcerpt( $text, $id = null ) {
       return wpautop(summary($text,110));
}

add_filter( 'the_title', 'trimTitle', 10, 2 );
add_filter( 'the_excerpt', 'trimExcerpt', 10, 2 );

} );

And on the page in the Elementor widget use “custom_excerpt” at the field “Query-ID”.

This trims the title to 80 characters and the excerpt to 110 characters. Of course you can set your own limits in the code snippet.

Maybe this helps a few people until Elementor actually addresses the issue.

Lots of stuff uses the excerpts. It would be great to just add the Post Meta Excerpt back in for the Episode Post Type.

1 Like