Recognise Custom Toc Function

#266600
  • Resolved Cali Dewberry
    Rank Math free

    HI, I found an article that enables you to get rank math to recognise custom TOC plugins. However, I am using a JS function. What would I need to get rank math to recognise this? Thanks, Cali


    (function ($) {

    $('#main').find('h2').each(function() {
    var $item = $(this);
    var $id = $(this).attr('id');
    var li = $('<li/>');
    var a = $('<a/>', {text: $item.text(), href: '#' + $id, title: $item.text()});
    a.appendTo(li);
    $('#main .toc ul').append(li);
    });

    })(jQuery);

    which I load through functions using this:


    wp_register_script('toc', get_stylesheet_directory_uri() . '/assets/js/toc.js', array(), false, true);
    wp_enqueue_script( 'toc' );

Viewing 1 replies (of 1 total)
  • Hello,

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

    We can’t recognize JavaScript code for the TOC generation, so you might need to completely disable the test by following this: https://rankmath.com/kb/table-of-contents-not-detected/#disable-toc-filter

    ​​​​​​​Hope this helps solve your issues.

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

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Recognise Custom Toc Function’ is closed to new replies.