Support » Plugin: Powerkit – Supercharge your WordPress Site » How to exclude a certain header from the Table of Contents

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have a similar problem: If you add post previews using your plugin, the h2 h3 tag is used and is automatically added to the table of contents. How could I achieve that post suggestions are not included in the TOC?

    Plugin Author codesupplyco

    (@codesupplyco)

    /**
     * Toc exclude selectors.
     *
     * @param string $selectors The selectors. Only single level.
     */
    function your_toc_exclude( $selectors ) {
    	$selectors .= '|.tag-selector-1|.tag-selector-2';
    	return $selectors;
    }
    add_filter( 'pk_toc_exclude', 'your_toc_exclude' );

    Thanks for your reply! I added the snippet. Unfortunately, it has no effect in my case.

    Plugin Author codesupplyco

    (@codesupplyco)

    If you need to exclude posts, then the code will be like this:

    /**
     * Toc exclude selectors.
     *
     * @param string $selectors The selectors. Only single level.
     */
    function toc_exclude( $selectors ) {
    	$selectors .= '|.pk-title|.cnvs-block-posts-title';
    	return $selectors;
    }
    add_filter( 'pk_toc_exclude', 'toc_exclude' );

    Great – that works!! Many thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.