Support » Theme: Oprum » Failure to strip shortcodes from home page excerpts

  • Resolved ali1632


    Hi, I’m seeing shortcodes output as text in the excerpt section of the recent posts on category pages. (It seems to work on the home page excerpts) I’m not sure why the built-in WordPress function to strip the shortcodes is not working – is there a custom excerpt generator in use for category pages?
    [edited to differentiate between homepage excerpts vs. category page excerpts]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try to strip shortcodes using below code. Put the code in functions.php file in your theme.

    add_filter( ‘the_excerpt’, ‘remove_shortcodes_from_excerpt’ );
    function remove_shortcodes_from_excerpt( $excerpt ) {
    return strip_shortcodes( $excerpt );

    Have tried this, no results. What I believe is that the category page is not using ‘the_excerpt’ but I am not familiar enough with how these functions are called to be able to find it.

    This test proved they are different:

    function remove_shortcodes_from_excerpt( $excerpt ) {
    //return strip_shortcodes( $excerpt );
    return "show this text" . $excerpt;
    add_filter( 'the_excerpt', 'remove_shortcodes_from_excerpt' );

    The above adds “show this text” to the front of the homepage excerpts, which are acting correctly, but does not affect the excerpts on the category pages, where the shortcodes are printing. I’m very new to this, and probably way over my head, but I’m hoping there’s a simple explanation, or an aha-moment of some kind, in my near future. Thanks for suggestions!

    I think I’ve found the custom excerpt, and can change it back to the standard. Resolving! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Failure to strip shortcodes from home page excerpts’ is closed to new replies.