As seen in the current theme, I am using jQuery to animate the show/hide or as known as the css style display: none;
.
Since I am using a custom child theme on my site, and have Hybrid theme as my parent, the widgets or sidebar section is different than may be in your theme. But just apply the the style’s as follows to your theme.
First make sure that your WordPress site is calling jQuery, by plugging in this code into your header.php
file above the <?php wp_head(); ?>
text:
<?php wp_enqueue_script('jquery'); ?>
Then anywhere above the </head
>, plug this code in:
<script type="text/javascript"> function toggleWidgets() { $('#primary h3.widget-title').addClass('plus'); $('#primary h3.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); }); } $(document).ready(function() { toggleWidgets(); } </script>
That’s it. Pretty simple huh.
So lets go over what the code does.
$('#primary h3.widget-title').addClass('plus');
This line finds all <h3>
tags with the class widget-title
inside the ID parameter of #primary
and adds a class of plus
.
Then
$('#primary h3.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); });
Will apply a click function. When the H3 tag is clicked it will remove the class plus
and add the class minus
.
Then the code that says .next
will then toggle the “next” element after the <h3> title.
Classic CTR Themes For WordPress have made it pretty easy to build informational websites using…
In today's techno-centric culture, you simply must have a business website, no matter how small…
Photography is the art of capturing naturalistic images with the help of photographic cameras. It…
Have you opened up a new website or a business and want to drive more…
WordPress has evolved greatly from its origin as a powerful blogging platform to an effective…
Busіnеsѕеs аnd orgаnіzatіоns аll аrоund the wоrld arе loоking fоr а ѕоlutiоn thаt wоuld prоvе…