ThemeShaper Forums » Thematic

Toggle/Show/Hide a widget or div.

(2 posts)
  • Started 4 years ago by Brydave
  • Latest reply from Chris
  • This topic is not resolved
  1. Brydave
    Member

    Hi everyone,

    I found this tutorial at wpcult.com, and am trying to implement it in my header, however I can't seem to get it to work.

    link to tutorial:
    http://wpcult.com/how-to-showhide-a-widget-in-wordpress-with-jquery/

    basically I've added a widgetized area in my header by adding it into my functions.php:

    <code>register_sidebar(array(
           	'name' => 'Expand Aside',
           	'id' => 'expand',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "",
    		'before_title' => "<h3 class=\"widgettitleexpand\">",
    		'after_title' => "</h3>\n",
        ));

    The widget displays fine, and I've changed the tutorial code accordingly:
    (#expand is the div id I added to the #header)

    <script type="text/javascript">
    //for toggling widgets
    function toggleWidgets() {
    	jQuery('#expand h3.widgettitleexpand').addClass('plus'); 
    
    	jQuery('#expand h3.widgettitleexpand').click(function() {
    		$(this).toggleClass('plus').toggleClass('minus').next().toggle(180);
    	});
    
    } jQuery(document).ready(function() {
    	toggleWidgets();
    	}
    </script>

    I don't know if it's just not using wp_enqueue_script('jquery'); or what, so any suggestions would be really appreciated since I am definitely a jquery noob...

    Thanks again!

    Posted 4 years ago #
  2. Hi,

    you forgot a ) before closing the script tag.

    Chris

    Posted 4 years ago #

RSS feed for this topic

Reply

You must log in to post.