Site logo

Archived topic

Functions php or Elements

8 replies · Started by Christos on May 6, 2022

Viewing posts 1–9 of 9

Hi. I have a piece of code to add to change Rankmath FAQ into accordion faqs display.
There is a CSS part and a js part. https://rankmath.com/kb/turn-faq-block-into-accordion/
About the functions.php part. Is there a different way to add that using elements or not? I want to avoid the Child theme.

Hi there,

change the Hook to wp_footer
And replace the hooks content with just the <script> ie:

<script>
    jQuery(document).ready(function() {
        var faqBlock = jQuery("div#rank-math-faq");
        var faqItems = faqBlock.find("div.rank-math-list-item");
        faqItems.bind("click", function(event) {
            var answer = jQuery(this).find("div.rank-math-answer");
            if (answer.css("overflow") == "hidden") {
                answer.css("overflow", "visible");
                answer.css("max-height", "100vh");
            } else {
                answer.css("overflow", "hidden");
                answer.css("max-height", "0");
            }
        });
    });
</script>

ΟΚ seems to work. thanks.

You're welcome

Its not working on my desktop either.
Edit the Element and set the Priority to a really high value eg. 1000 this will ensure the scripts loads after jQuery is loaded.

OK. seems to be solved.

Glad to hear that!

This archived topic is closed to new replies.