Ho wow to Add Accordion feature on ToC RankMath?

#530252
  • Resolved Febri Tri Harmoko
    Rank Math free

    I need help, can you add accordion feature on ToC RankMath. Or do you have trick to make your ToC have show-hide button?

    Thank you.

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

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

    I’m sorry to inform you that, by default there is option available for that but if you want you can use the following customize CSS on your site to add an accordion:

    .wp-block-rank-math-toc-block {
    	position:relative;
    }
    
    .wp-block-rank-math-toc-block h2 {
        background: #f1f2f6;
        padding: 10px 12px 10px 18px;
        cursor: pointer;
        font-size: 18px !important;
        font-weight: normal !important;
        position:relative;
        margin-bottom: 0;
    }
    .wp-block-rank-math-toc-block h2:before {
    	display:inline-block;
    	content: "";
            width: 0;
    	height: 0;
    	border-style: solid;
    	border-width: 6px 0 6px 12px;
    	border-color: transparent transparent transparent #000000;
    	margin-right: 8px;
    }
    
    .wp-block-rank-math-toc-block nav{
    	padding: 10px 10px 0px 10px;
    	max-height: 0;
    	overflow:hidden;
    }
    .wp-block-rank-math-toc-block input:checked+h2~nav {
    	max-height: 100vh;
    	overflow:visible;
    }
    

    Here’s a guide you can follow to add this custom CSS on 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/i82VnJ3Z

    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.

    Thank you, it’s work.
    But I have a problem using ToC with more than 20 items.

    Look at this article https://xkomo.com/review-rog-phone-6/

    Hello,

    We would need to change 2 things in the CSS and JS. In the CSS please change 100vh to 200vh:

    .wp-block-rank-math-toc-block input:checked+h2~nav {
    	max-height: 200vh;
    	overflow:visible;
    }

    Also, in https://pastebin.com/i82VnJ3Z change the value as suggested in the image: https://i.rankmath.com/i/ZJPaNg

    Hope this helps.

    Thank you

    Thank you, it’s work for me 🙂

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

The ticket ‘Ho wow to Add Accordion feature on ToC RankMath?’ is closed to new replies.