Skip to content
Advertisement

End excerpts with a full sentence for specific post types

I am trying to make excerpts end with a sentence, for a specific post type on my website, but for some reason, it is also effecting page excerpts and I cannot understand why.

JavaScript

It doesn’t effect any of my other custom post types, just the one I specify in the function, and then all pages on the website. It still effects my pages, even if I change the logic to something like = poi && != page as well. Any ideas why this would also be effecting pages? Is there an easier way to make this happen?

Thanks!

Advertisement

Answer

There is a multitudes of ways we can approach it. Taking the time to write a custom excerpt instead on relying on WordPress is one of them…

We can count sentences by targeting end-of-sentence period.

JavaScript

You can specify what type of content should be ‘truncated’ and by how many sentences. On the front-end we can call our function get_tally_excerpt() like so:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement