• Resolved adamfartassi

    (@adamfartassi)


    Hello,
    I’m having an issue with the generated excerpt by Relevanssi which show the content from the inside of the table of contents in my posts. I’m using the plugin Easy Table of Contents which show a table of contents from a shortcode.
    Is there a way to exclude all the content inside of the table of contents?
    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Add this to your theme functions.php to stop Relevanssi including the table of contents in the excerpts:

    add_filter( 'relevanssi_disable_shortcodes_excerpt', 'rlv_block_ez_toc' );
    function rlv_block_ez_toc( $shortcodes ) {
        return array_merge( $shortcodes, array( 'ez-toc', 'toc' ) );
    }
    Thread Starter adamfartassi

    (@adamfartassi)

    Thanks that did the trick.
    But now I see instead of the table of contents the keyword “[ez-toc]” showing on the excerpt, is there a way to hide it as well?
    Best regards.

    Plugin Author Mikko Saari

    (@msaari)

    You can add this:

    add_filter( 'relevanssi_pre_excerpt_content', 'rlv_remove_ez_toc' );
    function rlv_remove_ez_toc( $content ) {
        return str_replace( '[ez-toc]', '', $content );
    }

    That’s actually something Relevanssi should probably do automatically; I’ll add that in the next version.

    Thread Starter adamfartassi

    (@adamfartassi)

    Thanks that fixed it. I’ll mark this as resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Excluding table of contents from excerpt’ is closed to new replies.