Disable the generation of the table of content using custom conditions.
The function must return true to disable the generation of the TOC.
Arguments:
$value: $value is set to false by default, you should ignore this parameter.
$content: Current post content.
$post: $post object.
add_filter('joli_toc_disable_toc_custom', 'toc_disable', 10, 3);
function toc_disable($value, $content, $post)
{
//TOC will be disabled if the page contains the word "travel"
if (strpos($content, 'travel') !== false) {
return true;
}
//default to false
return $value;
}
Disable the auto-insertion of the TOC on the Homepage (Front page):
add_filter('joli_toc_disable_toc_custom', 'toc_disable', 10, 3);
function toc_disable($value, $content, $post)
{
// Disable TOC on homepage
if (is_front_page() || is_home()) {
return true;
}
return $value;
}