0

I'm looking for a way the edit the excerpt before it get's show on the page.

The issue is this: We import data (jobs) for a third party provider and the content is divided in sections with each a header (e.g. the first one is "Introduction"). The issue now is that in the overview with the post, each excerpt looks like "Introduction. Lorem Ipsum". So I want to manipulate the data to remove "Introduction."

Are there any hooks in WordPress that I can utilize to either edit the data before shown, or is there a function that I can overwrite that display's the_excerpt()?

I'm using a child theme of a theme we bought and would prefer to not mess with the core files.

0

Well, I found it:

    function get_the_excerpt_filter( $excerpt ) {
        $wordToRemove = "Introduction";
        $len = strlen($wordToRemove);

        if(substr($excerpt, 0, $len) == $wordToRemove){
            $excerpt = trim(substr($excerpt, $len));
        }

        return $excerpt;
    }
    add_filter( 'get_the_excerpt', 'get_the_excerpt_filter' );

Hope this helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.