Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Build a WordPress Theme Extending WordPress Template Functionality Adding Widgets to Our Footer

before_title/after_title not being applied

When I add the widgets, the before_title/after_title key => value pairs specified in the array for create_widget is not being applied or is being overridden. Edit: This only occurs on the Dribble Plugin. I did not test the twitter one, but the Treehouse Badges Plugin has the correct h5 tags applied. Here's the relevant code from functions.php

function create_widget($name, $id, $description) {

  register_sidebar(array(
    'name' => __( $name ),   
    'id' => $id, 
    'description' => __( $description ),
    'before_widget' => ' ',
    'after_widget' => ' ',
    'before_title' => '<h5>',
    'after_title' => '</h5>'
  ));

}

create_widget("Left Footer", "footer_left", "Displays in the left of the footer");
create_widget("Middle Footer", "footer_middle", "Displays in the middle of the footer");
create_widget("Right Footer", "footer_right", "Displays in the right of the footer");

The widget is being displayed, but the title has h3 instead of the expected h5 tags.

I assume I may be missing something simple, but haven't been able to find a solution. Any tips on what I should check/do to resolve this problem?

1 Answer

Cameron Bourquein
Cameron Bourquein
4,927 Points

This is happening to me too. It appears the Dribble Widget has a new field of "title" relative to when this tutorial was recorded, which is overriding the h5 tags with its own h3. The only way I was able to alter this was to Go to the Dashboard -> Plugins -> WP Dribbble (Edit) and change this bit of code in the plug-in itself:

<!-- Custom Dribbble Widget Title -->
<h3><?php if(!empty($widgetTitle)) : echo $widgetTitle; else : echo 'Dribbbles'; endif; ?></h3>

Such that the h3 tags are h5 tags. Still have some other restyling to do, but it did fix the heading problem. I don't know what the best practice would be for fixing something like this as I am still quite new to WP, php, etc., but this is what worked for me.