Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Convert Rank Math FAQ Block Into Accordion
- */
- function turn_rm_faq_to_accordion() {
- ?>
- // First try loading jQuery from Google's CDN
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
- // Fall back to a local copy of jQuery if the CDN fails
- <script>
- window.jQuery || document.write('<script src="http://mysite.com/jquery.min.js"><\/script>'))
- </script>
- <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>
- <?php
- }
- add_action( 'wp_footer', 'turn_rm_faq_to_accordion' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement