Hello,
Thank you for reaching out to us. Yes, you can automatically insert a Table of Contents (TOC) in old articles using Rank Math. You can achieve this by adding a piece of code to your theme’s functions.php file or rank-math.php file. Here’s the code snippet you’ll need to add:
/**
* 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 this code, Rank Math will be able to detect that you are using a Table of Contents section in your old posts.
If you need further assistance with this, please feel free to ask.
Thank you for your time and patience.
Sources:
Score 100/100 With Rank Math Post Tests » Rank Math
Why Isn’t Rank Math Detecting the Table of Contents? » Rank Math
How to Add Rank Math’s Table of Contents Block » Rank Math
I understand that. but it’s supposing that I already used TOC before. wich I did not.
is there a work around?
thank you for your time
Hello,
Thank you for contacting Rank Math support.
Unfortunately, it isn’t possible to automatically include the TOC in existing posts. You will have to add the TOC block manually. You can use another TOC plugin like Easy Table of Contents to automate the TOC insertion.
I hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.
Thank you, Jaideep.
I’ll do just that.
Hello,
We are super happy that we were able to address your concerns.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.