TOC not working when schema turned off.

#752456
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    I apologize for the inconvenience you are facing with the Table of Contents (TOC) plugin after deactivating the Schema in the dashboard.

    Based on the information provided, it seems that when you turned off the Schema, it affected the Table of Contents plugin functionality. To resolve this issue, you can follow these steps:

    1. Disable Test for Table of Contents:
      If you are not using a TOC plugin and want to disable the TOC test in Rank Math, you can add a code snippet to your theme’s functions.php file or rank-math.php file. Here is the code snippet you can use:

      /**
       * Filter to disable the table of contents test.
       */
      add_filter( 'rank_math/researches/tests', function( $tests, $type ) {
          unset(
              $tests['contentHasTOC'],
          );
          return $tests;
      }, 10, 2 );
    2. Adding Your Plugin to TOC List:
      If you are using a TOC plugin that is not included in Rank Math’s supported list, you can create a rank-math.php file and add a filter to include your plugin in the TOC list. Here is an example code snippet:

      /**
       * 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;
      });

    By following these steps, you should be able to resolve the issue with the Table of Contents plugin not working after deactivating Schema. If you encounter any further issues or need additional assistance, please feel free to reply to this ticket.

    Thank you for bringing this matter to our attention. We are here to help you.

    Closing Regards,
    Rank Math Support Team

    Sources:
    Why Isn’t Rank Math Detecting the Table of Contents? » Rank Math
    Removing Schema From Your Posts & Pages » Rank Math
    How to Use a Table of Contents to Improve Content Readability » Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    Please ignore the reply from the RankBot. In order to use the Rank Math Table of Contents, you’ll have to enable the Schema Module in Rank Math > Dashboard. Otherwise, the Table of Contents will not work.

    However, if you don’t want to use the Rank Math schema but only want to use the Table of Contents then you can use the following filter on your website to disable the schema from Rank Math:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return false;
    }, 99, 2);
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

    SoundShockAudio
    Rank Math pro
    Content AI Starter

    Thank you for giving me instructions for the code to add so i can disable the schema but use the rank math TOC

    Unfortunatley this didn’t work when I created the rankmath.php file in my theme, Pro Child Theme.

    https://i.imgur.com/UUU2aFH.png

    The code was added to the header of my site and it didn’t fix the TOC on the pgaes that it was on.

    Any help fixing this would be appreciated.

    SoundShockAudio
    Rank Math pro
    Content AI Starter

    I deactivated the Schema in the dashboard and this turned off the table of contents plugin.

    Is there any way to have the TOC rank math plugin working with the schema turned off?

    Here are some posts where the TOC is on:

    https://soundshockaudio.com/orangeflavor/
    https://soundshockaudio.com/origin-by-cymatics/
    https://soundshockaudio.com/ferrictds-mkii-2/

    Hello,

    The filter was not added correctly to the website, otherwise it wouldn’t show like that on the page.

    You need to add an opening PHP tag to the file before adding the PHP code we added before.

    The easiest way to do this would be with the code snippets plugin as mentioned in the article we shared previously. If you still want to go ahead and use the file method, please note that the file should be named rank-math.php, the dash is a requirement.

    Also, the contents of the file should be the following:

    
    <?php
    
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return false;
    }, 99, 2);
    

    Don’t hesitate to get in touch if you have any other questions.

    SoundShockAudio
    Rank Math pro
    Content AI Starter

    Thank you. I added the <?php to the top of the rank-math.php file in my theme.

    The TOC shows up but the text Table of Contents is still missing from the Rannk Math TOC.

    Also, when I go to edit the post, I still get this error
    https://i.imgur.com/cxwsPYs.png

    Hello,

    I can check that the Schema module is still disabled on your site. You will have to enable the Schema module to enable the TOC block. The code we shared will make sure that the Schema is not added by our plugin even if the Schema module is enabled.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    SoundShockAudio
    Rank Math pro
    Content AI Starter

    Ahh okay thank you. This worked!

    Hello,

    We are super happy that this resolved your issue.

    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.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘TOC not working when schema turned off.’ is closed to new replies.