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?
/**
* 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.
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!