Collapsible TOC Drop Down Arrow

#707364
  • Resolved Michael Van Gerpen
    Rank Math free

    I followed all of the steps to make the Rank Math Table of Contents collapsible, which worked perfectly. However, I’d like to add a button that says “show” or “hide” respectively, or some type of drop down arrow. Is that possible?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello, I’m glad to hear that you were able to make the Rank Math Table of Contents collapsible successfully. As for adding a button that says “show” or “hide” or a drop-down arrow, it is possible to customize the appearance of the collapsible Table of Contents block further.

    You can achieve this by adding custom CSS and JavaScript to your theme. You can add a button or a drop-down arrow using CSS and then use JavaScript to toggle the visibility of the Table of Contents block when the button or arrow is clicked.

    If you need assistance with the specific CSS and JavaScript code to achieve this customization, please let us know, and we’ll be happy to guide you through the process.

    If you have any other questions or need further assistance, feel free to ask!

    Sources:
    How to Add Rank Math’s Table of Contents Block » Rank Math
    Score 100/100 With Rank Math Post Tests » Rank Math
    How to Use a Table of Contents to Improve Content Readability » Rank Math

    Thank you for the response. I definitely need help with the CSS for this request.

    Hello,

    Thank you for contacting us and bringing your concern to our attention.

    You can use the following Custom CSS on your website and see if that works for you:

    .wp-block-rank-math-toc-block {
        position: relative;
    }
    
    .wp-block-rank-math-toc-block h2 button.toggle-button {
        background: #ddd !important;
    	  color: #000 !important;
        padding: 10px 12px;
        cursor: pointer;
        font-size: 18px !important;
        font-weight: normal !important;
        position: relative;
        margin-bottom: 0;
        border: none;
        display: flex;
        justify-content: space-between;
    }
    
    .wp-block-rank-math-toc-block h2 button.toggle-button:focus{
    	outline: none !important;
    }
    
    .wp-block-rank-math-toc-block nav {
        padding: 10px 10px 0px 10px;
        max-height: 0;
        overflow: hidden;
        transition: all linear .3s;
    }
    
    .wp-block-rank-math-toc-block input:checked + h2 ~ nav {
        max-height: 100%;
        overflow: visible;
    }
    

    Here’s a guide you can follow to add this custom CSS to your site:
    https://www.wpbeginner.com/plugins/how-to-easily-add-custom-css-to-your-wordpress-site/

    Once done, please add this filter to your site: https://pastebin.com/CU2Dibux

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

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    I added the the CSS first and that didn’t change anything. The TOC continued to be collapsible, but without a button.

    I then added the filter. Once I did, the TOC would no longer expand. It just stays collapsed. And there isn’t a button.

    Hello,

    In this case we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

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

    Thank you.

    I just added the info you requested. Please let me know if you need anything else.

    Hello,

    I tried disabling the current snippet you created to add collapsible TOC in your posts but it seems the TOC is still showing the same state:

    Rank Math support

    I also tried enabling plugin troubleshooting mode by enabling only Rank Math and a default WP theme and the same issue is happening.

    Can you please confirm how you have applied the CSS? At the moment, your WP dashboard doesn’t allow us to edit the theme files, and the FTP login you shared is not working.

    Looking forward to helping you.

    I applied the CSS by going to the left-side navigation bar, selecting Appearance > Customize > Additional CSS and then if you scroll all the way to the bottom you’ll see the code.

    Is that what you’re asking for?

    Hello,

    The code you added was targeting an H2 and the title of the TOC is currently set to an H4. We changed the code to target that selector and it’s showing the button and also is currently collapsing and expanding correctly.

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

    Thank you!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    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.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

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

The ticket ‘Collapsible TOC Drop Down Arrow’ is closed to new replies.