This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Themeblvd Add Sidebar Location Function not working

  • Creator
    Topic
  • #10183
    askwpgirl
    Participant

    After updating theme and WordPress, the following function no longer works, and the widget area that had existed has disappeared. Is there a new function to use to add sidebar locations in the child theme’s functions file?

    themeblvd_add_sidebar_location( 'expertise_menu', 'Expertise Menu', 'collapsible' );
Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #10184
    askwpgirl
    Participant

    AH! I think I figured it out. I had a function in the top of the child theme to override the themeblvd add sidebar function so as to add an additional span to the before and after title options in the sidebar registrations. Removing this fixed the problem. Now I just need to fresh the new function for the widget area formatting.

    #10185
    askwpgirl
    Participant

    So, how can I modify this in my child theme’s functions file:

    // Add in shared arguments
    		foreach ( $this->core_locations as $id => $location ) {
    			$this->core_locations[$id]['args']['before_widget'] = '<aside id="%1$s" class="widget %2$s"><div class="widget-inner">';
    			$this->core_locations[$id]['args']['after_widget'] 	= '</div></aside>';
    			$this->core_locations[$id]['args']['before_title'] 	= '<h3 class="widget-title">';
    			$this->core_locations[$id]['args']['after_title'] 	= '</h3>';
    		}

    I had to hack the TB Widget Areas plugin to get another HTML span inside the before_title and after_title options. I often have designs with slightly more complicated HTML needs, so it’s important for me to be able to modify these values both for the theme’s widget areas as well as custom widget areas created via the TB Widget Areas plugin.

    #10209
    Jason Bobich
    Keymaster

    No need for any hacking. This is what the filters are for. If you look there, you have many different ways you can modify these items. I think a couple of the filters have even been there since I added them after a similar conversation we had awhile back.

    So, do you want to modify just the widget area location you’re adding, or all widget area locations? What exactly are you trying to accomplish?

    #10229
    askwpgirl
    Participant

    Excellent. I want to add a span to the before_title and after_title HTML for ALL widget areas including the ones output by the custom widget areas plugin. See screenshot:

    http://tinypic.com/r/wais5s/5

    #10239
    Jason Bobich
    Keymaster

    So I think this should do it for you:

    function my_sidebar_args( $args ) {
    
    	$args['before_title'] = '<h3 class="widget-title"><span>';
    	$args['after_title'] = '</span></h3>';
    
    	return $args;
    }
    add_filter( 'themeblvd_default_sidebar_args', 'my_sidebar_args' );

    Does that do what you’re wanting?

    #10286
    askwpgirl
    Participant

    Yes, that takes care of all the default widget locations (good), but it doesn’t effect the HTML for the widget areas defined by the TB Widget Areas plugin. That’s where I needed to hack the plugin file to get the span in there.

    #10287
    Jason Bobich
    Keymaster

    Aw, got it. So, I’m looking through and there’s another filter that works similarly.

    https://github.com/themeblvd/theme-blvd-widget-areas/blob/master/includes/general.php#L117

    You should be able to use your one callback function and apply it to both filters.

    function my_sidebar_args( $args ) {
    
    	$args['before_title'] = '<h3 class="widget-title"><span>';
    	$args['after_title'] = '</span></h3>';
    
    	return $args;
    }
    add_filter( 'themeblvd_default_sidebar_args', 'my_sidebar_args' );
    add_filter( 'themeblvd_custom_sidebar_args', 'my_sidebar_args' );
    #10400
    askwpgirl
    Participant

    Worked like a charm! Good lesson.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.