• Hi,
    I’m trying to get my shortcodes to play nice with my excerpts, and I’m getting nowhere.

    I know that this has been answered numerous times, but I’ve read and tried everything that I can.

    I just don’t know a heck of a lot about PHP.

    I’ve tried many variations of the following in my child theme’s functions.php, but all to no avail.

    <?php
    add_filter('get_the_excerpt', 'do_my_shortcode_in_excerpt');
    function do_my_shortcode_in_excerpt($excerpt) {
        return do_shortcode(wp_trim_words(get_the_content(), 55));
    }

    Can anyone lend a hand?

    Thanks,
    Chris

Viewing 2 replies - 1 through 2 (of 2 total)
  • It is possible that you need to add the filter to ‘the_excerpt’ rather than ‘get_the_excerpt’. Which one is called in the template code?

    Thread Starter czucker

    (@czucker)

    I actually got a fix for it from the theme developer. I don’t like it because he has me modifying the shortcodes.php file and I’d much prefer to handle this in the child theme.

    I think you may be correct, I believe the template has ‘the_excerpt.’

    I will give that a try.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcodes and excerpts’ is closed to new replies.