1. Home
  2. Knowledge Base
  3. SEO Suite
  4. Why isn’t Rank Math Detecting the Table of Contents?

Why isn’t Rank Math Detecting the Table of Contents?

You might have come across scenarios where Rank Math is not able to detect the Table of Contents. In this article, we will discuss why Rank Math is not able to detect the Table of Contents and what you can do about that…

Why isn't Rank Math Detecting the Table of Contents? - Rank Math SEO

TOC Plugins Detected by Rank Math

Since there is no specific method to look for a Table of Contents inside your HTML code, Rank Math will check for the presence of a Table of Contents creation plugin on your site.

Assuming that you will use the Table of Contents and you have the plugin installed, Rank Math can detect the Table of Contents if any one of the below-supported plugins is used:

Adding Your Plugin to TOC List

But, if your plugin is not included in the above list, then you may need to add the following piece of code in your theme’s functions.php file or rank-math.php file.

/**
 * Filter to add plugins to the TOC list.
 *
 * @param array TOC plugins.
 */
add_filter( 'rank_math/researches/toc_plugins', function( $toc_plugins ) {
       $toc_plugins['plugin-directory/plugin-filename.php'] = 'Plugin Name';
    return $toc_plugins;
});

In the above code snippet, you’ll need to replace,

  • plugin-directory/plugin-filename.php – with the path to your TOC plugin file inside the WordPress plugins folder
  • Plugin Name – with the name of your TOC plugin

Once you’ve added the above piece of code, Rank Math can detect that you are using a Table of Contents section in your posts. We recommend adding this code to a child theme so that even when your theme developer releases updates to your main theme, changes are not overridden.

Disable Test for Table of Contents

In case if you’re adding Table of Contents by any other method that does not involve the usage of a plugin, then you can completely disable the test for Table of Contents.

To disable the test of Table of Contents, add the following piece of code to your theme’s functions.php file or rank-math.php file.

/**
 * Filter to disable the table of contents test
 */
add_filter( 'rank_math/researches/tests', function( $tests, $type ) {
    unset(
        $tests['contentHasTOC'],
    );
    return $tests;
}, 10, 2 );

Once the code snippet has been added, Rank Math will completely ignore the test for Table of Contents while analyzing your content.

And, that’s it! We hope the tutorial helped you fix the issue. If you’re still facing the issue, please feel free to open a support ticket directly from here, and we’re always here to help.

Still not using Rank Math?

Setup takes less than 5 minutes including the import from your old SEO Plugin!

Know more about the PRO Version

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles