Create different flavours of excerpt

Question

I have an understanding problem with the WordPress filter approach.

I thought that I could easily use something like the_excerpt() on one hand and create the the_excerpt_function_for_this_special_page() on the other hand. However, it turns that I’m really lost between the filters and functions and I do not know how to achieve my goal.

What I want to build

I added a filter to the get_the_excerpt filter as follows:

function the_readmore_excerpt( $excerpt ) { 
    return $excerpt. '.. <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Mehr lesen', 'baskerville') . ' &rarr;</a>'; 
} 

add_filter('get_the_excerpt', 'the_readmore_excerpt');

That’s working well except that it appears on every excerpt on the website (that’s actually expected).

Question

How do I get 2 different excerpts: one with read more and one without (based on this code)?

0
, Laurent Meyer 7 months 0 Answers 87 views 0

Leave an answer