WordPress.org

Support

Support » Themes and Templates » [Resolved] Have the bottom widget area open by default

[Resolved] Have the bottom widget area open by default

  • I have added this line to my child theme’s css:
    #secondary {display: block;}
    so now the bottom widget area is open by default.
    however, the sidebar-link is showing “+” by default and I need to change it to default to “-“.
    how can I do that?
    thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

    Looks like you need to enqueue a JS file with this code in it:

    jQuery( document ).ready( function( $ ) {
    
    	var $sidebar = $( '#main' );
            // Toggle sidebar on
    	$( '.sidebar-link' ).unbind( 'click' ).click( function() {
    		$( 'html,body' ).animate( { scrollTop: $( "#secondary" ).offset().top },'slow' );
    		$sidebar.find( '#secondary' ).slideToggle( 'ease' );
    		$(this).toggleClass( 'toggled-on' );
    		if ( $(this).hasClass( 'toggled-on' ) )
    			$(this).text( '+' );
    		else
    			$(this).text( '-' );
    	} );
    });

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    not sure how to implement this.
    isn’t there a way to modify the existing PHP or JS files?
    Thank you.

    I’ve impelemented the jQuery and enqueued it and although it does change the “+” and “-” symbols as they should be when clicked, it does not change the default state the site loads in.
    by default, the site loads with the bottom sidebar open but the link shows “+” when it should show “-“.
    when I click it, it closes the bottom area and the symbol remains “+”.
    so when I click it again, it now opens and the symbol is “-” as it should be.
    how can I make the default state to be “-“?
    Thank you.

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    Try something like this outside of the click event:

    $( '.sidebar-link' ).text('-');

    Btw it would help if you could link the page in question

    not sure where to add this line. where is “outside the click event”?
    this is the url: http://www.private.fsh.co.il
    thanks.

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    Instead of this:

    jQuery( document ).ready( function( $ ) {
    
    	var $sidebar = $( '#main' );
            // Toggle sidebar on
    	$( '.sidebar-link' ).unbind( 'click' ).click( function() {
    		$( 'html,body' ).animate( { scrollTop: $( "#secondary" ).offset().top },'slow' );
    		$sidebar.find( '#secondary' ).slideToggle( 'ease' );
    		$(this).toggleClass( 'toggled-on' );
    		if ( $(this).hasClass( 'toggled-on' ) )
    			$(this).text( '+' );
    		else
    			$(this).text( '-' );
    	} );
    });

    Use this:

    jQuery( document ).ready( function( $ ) {
    
            $( '.sidebar-link' ).text('-');
    	var $sidebar = $( '#main' );
            // Toggle sidebar on
    	$( '.sidebar-link' ).unbind( 'click' ).click( function() {
    		$( 'html,body' ).animate( { scrollTop: $( "#secondary" ).offset().top },'slow' );
    		$sidebar.find( '#secondary' ).slideToggle( 'ease' );
    		$(this).toggleClass( 'toggled-on' );
    		if ( $(this).hasClass( 'toggled-on' ) )
    			$(this).text( '+' );
    		else
    			$(this).text( '-' );
    	} );
    
    });

    Thank you!
    works perfect.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Have the bottom widget area open by default’ is closed to new replies.