Rank Math TOC with fixed header, is there a way to offset

#943460
  • Resolved Adnan Faridi
    Rank Math free

    Hello

    I am using RankMath Free with Divi and currently using a third party navigation menu. The toc links scroll slightly past the h2, h3, etc.

    Is there a way to get it to offset the height by a few pixels. There was a forum post which was marked as resolved, but it did not work with me.

    thx
    adnan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    We apologize for the issue you are facing with the Rank Math Table of Contents (TOC) links scrolling slightly past the headings. To achieve an offset for your TOC links, you can use a bit of custom JavaScript or jQuery to adjust the scroll position when a link is clicked.

    Here’s a simple way to implement this:

    1. Add Custom JavaScript: You can add the following script to your theme’s functions.php file or through a custom JavaScript plugin:

      jQuery(document).ready(function($) {
         $('.wp-block-rank-math-toc-block a').on('click', function(event) {
             event.preventDefault();
             var target = $(this).attr('href');
             var offset = 100; // Adjust this value as needed
             $('html, body').animate({
                 scrollTop: $(target).offset().top - offset
             }, 500);
         });
      });

      In this code, you can adjust the offset variable to the number of pixels you want to offset the scroll position.

    2. Save Changes: Make sure to save the changes after adding the script.

    This should help in adjusting the scroll position when clicking on the TOC links. If you have any further questions or need assistance, feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further.

    Thank you for raising this concern!

    Hello,

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

    Please share a page URL where you’re using the Rank Math Table of Contents so that we can check this further for you.

    Looking forward to helping you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    We checked your page and the issue you’re currently facing is actually design-related which is controlled by the theme you’re using on your website.

    We directly checked with the ID of the heading in the URL and faced the same issue. Please check the screencast in the sensitive data section for reference.

    We suggest you get in touch with your theme support as they are in a better position to assist you.

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

    Hello and thank you

    Yes, that is because of the relative and fixed positioning of the header. It will be like that for all named anchors and that is why I asked you if there is a way to offset your TOC.

    Maybe if you have any setting that can offset these due to the header.

    Hello and thank you

    Divi said that it could be a bug and they are also checking it out.

    I appreciate the help.

    Hello,

    We are glad to be of help.

    Don’t hesitate to reach out if you have any other concerns or questions.

    Thank you.

    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 7 replies - 1 through 7 (of 7 total)

The ticket ‘Rank Math TOC with fixed header, is there a way to offset’ is closed to new replies.