Fix WordPress Sidebar Widgets That Don’t Work

You may have come across a cool WordPress theme that you really want to use on your but it might need just a bit of tweaking to make it standout or, in some cases work correctly. In this example what to do if your new themes widgets aren’t working.

This post is taken from the “Ask Max” page where I try to answer your questions about WordPress. First off I ask those posting questions on that page to not get too technical or into things such as template coding and things of that nature. And in this case the question actually wasn’t of that nature but the answer is.

Here is the Question:

When I try to customize the sidebars, nothing changes! No matter how I drag and drop widgets on them, they always look the same with same default categories & archives on the left and calendar blogroll, and meta on the left. Any idea why that is? Thanks.

After looking at the theme, jd-nebula-3c 1.0, and dealing with the arrogance on a certain forum that is supposed to help people with their , I figured out what the problem with theme is.

The are not working on this theme meaning that moving them around in the dashboard didn’t register a change on the blog itself. The first issue with this two sidebar theme was the functions.php file. so lets fix that first and without going into an in-depth explanation I am just going to show you the proper code to use in your functions.php file.

Warning! Before you change any code in your themes template files create a backup so you can restore it if it doesn’t work for you!

Below is the code needed in the functions.php file to use for a two sidebar theme. It basically says to get sidebar1 and sidebar2 if they exist. Replace the all the code in your functions.php file with this:

<?php
if ( function_exists(’register_sidebar’) )
register_sidebar(array(’name’=>’sidebar1′,
‘before_widget’ => ‘<div id=”%1$s” class=”side-c %2$s”>’, // Removes <li>
‘after_widget’ => ‘</div>’, // Removes </li>
‘before_title’ => ‘<h3>’, // Replaces <h2>
‘after_title’ => ‘</h3>’, // Replaces </h2>
));
register_sidebar(array(’name’=>’sidebar2′,
‘before_widget’ => ‘<div id=”%1$s” class=”side-c %2$s”>’, // Removes <li>
‘after_widget’ => ‘</div>’, // Removes </li>
‘before_title’ => ‘<h3>’, // Replaces <h2>
‘after_title’ => ‘</h3>’, // Replaces </h2>
));

?>

Next the sidebar file in this particular theme was calling up two sidebars that the functions.php file didn’t know about. We just fixed the functions.php file above and now we need to add the proper code in the sidebar.php file. Open your sidebar.php file and look for these two areas of text, the red text is the problem that needs addressed:

This is for the left sidebar:

<div id=”left-sidebar”>

<?php if ( function_exists(’dynamic_sidebar’) && dynamic_sidebar(’Sidebar_1′) ) : else : ?>

<div id=”categories”>

And a little further down is the right sidebar:

<div id=”right-sidebar”>
<?php if ( function_exists(’dynamic_sidebar’) && dynamic_sidebar(’Sidebar_2′) ) : else : ?>

You can see that these are calling for Sidebar_1 and Sidebar_2 but again the functions.php file had no reference to them. So now replace the red text in your sidebar.php file with this code:

For the left sidebar use this:

<div id=”left-sidebar”>

<?php if ( !function_exists(’dynamic_sidebar’) || !dynamic_sidebar(’sidebar1′) ) : ?>

And for the right sidebar use this:

<div id=”right-sidebar”>
<?php if ( !function_exists(’dynamic_sidebar’) || !dynamic_sidebar(’sidebar2′) ) : ?>

This is the fix for WordPress sidebar widgets that don’t work on the particular theme mentioned above. It may work on other but I offer no guarantees.

If you need help customizing or fixing your WordPress blog post a comment or click here to send me an email, you will find my fees are very reasonable.



Tags: ,

Related posts

If you liked this post, feel free to leave a comment that is relevant to the post or subscribe to the feed and get future articles delivered to your feed reader.

Sorry but due to the spamming of a few all comments are moderated and will appear when approved and all drive-by comments will be deleted!

Comments

Fix WordPress Sidebar Widgets That Don’t Work…You may have come across a cool WordPress theme that you really want to use on your WordPress blog but it might need just a bit of tweaking to make it standout or, in some cases work correctly. In this example what to do if your new themes widgets aren…</p>

Thanks very much Jeff, although could you help me figure out why it still doesn’t work for me?

When I copy the fix you say for functions.php exactly, I just get an error message like this for every page of the site or every page of wp-admin:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in /home/my_particular_directory/wp-content/themes/jd-nebula-3c-10/functions.php on line 9

Sometimes it says line 4 instead of line 9.

Does it matter whether you edit functions.php in the WP Theme Editor, or directly through my ftp program? Although in either case I got the same error after replacing the text of functions.php.

Thanks,

Reply

Nova, I did the same exact thing on a test blog for the theme you are using (jd-nebula-3c-10).

Here is a text file of the functions.php: http://www.wordpressmax.com/files/functions.txt

Click the link and the text file should open, try copying the code from there.

Reply

Still no luck, but thanks anyway!

Reply

Hey Jeff,
Thanks for the tips – this was driving me a bit batty and after observing the same “arrogance on a certain forum that is supposed to help people with their WordPress blog” I came looking for better answers. Thankfully, I found them here.

I did encounter the same problems Nova did – first with the functions.php code. The copy on your link worked fine, however – no parse error – but even after applying the stated changes to sidebar.php, I saw no change in my site.

I fixed it by sticking with the original code and simply altering ‘Sidebar_1′ and ‘Sidebar_2′ by making them ’sidebar1′ and ’sidebar2′ as used in your functions.php fix. It’s now calling correctly and my widgets are fully functional.

Your functions.php fix was the key – without it, I’d still be pulling my hair out. So thanks much! You rock!

Reply

I am using the jd-nebula-3c 1.0 theme on my site (tweaked by me)… but I am having a problems with comments parsing correctly. For some reason, I can’t seem to find why comments displayed remove the “p” tag between separated paragraphs by a double “br” entered into the comments input field.

Any tips?

Thanks in advance!

Tim

Reply

So sorry! My problem was with the errant CSS that came with the theme.


  #commentlist p {
    margin: 0;
    padding: 0;
}

Should have some extra padding down below, i.e.:


  #commentlist p{
                                           padding-bottom: 20px;
}

Sorry for the false alarm! :-)

Reply

Glad you got it fixed Tim!

Reply

Thanks, and this is a great site, btw!

Reply

Hey Jeff
Great idea, this site. Sorry it’s been a long time.
Problem is as follows:
When i preview my blog it shows my text widget and blog archives etc but none of this appears when viewing the site live on the web.
Hope you can help.
I don’t mind paying as I know you’ll do a great job.
all the best,
paul

Reply

Paul, when asking for help for your blog please include a link to it. Even then I may not be able to help unless I can have access to the dashboard.

Jeff

Reply

[...] Just replace the original functions.php of your theme with a new one which should look like this (via): [...]

Check out my blog…I can’t make those pictures and blogroll widgets appear in the righthand column all the time. I know it’s because one of my many posters is putting images too big—-is there a way to automatically resize things already posted and automatically size future images so that the widgets pop back into place where they need to be (instead of being dumped at the bottom of the page as they are now?) THANKS

Reply

Don I know of no way to do what you are asking other that training your authors to keep images to a certain size. There may be a plugin that can do this or a code tweak in the theme or script itself for self-hosted WordPress blogs but your blog is on WordPress.com, I know very little about the blogs on WordPress.com other than it limits your customization options. I suggest taking your question to the WordPress.com forum.

Reply

thank you for the information, it is very usefull, above all for persons as me that is new in the world of blogs

Reply

Okay,

I did the fix you suggested, and made a backup first and have the same problem as Nova.

Parse error: syntax error, unexpected T_STRING, expecting ‘)’ in /home6/my_site/public_html/wp-content/themes/black-lucas/functions.php on line 4

I have the original file backed up but now I can’t get back into wpadmin to change it back. I have ftp’d the entire theme back onto the site and I still get the same error.

Yikes.. what did I do???

Reply

Sorry.. simple school boy error from a newbie. Was just a case of mistaken idirectory :-)

I still have to play around with the widgets to get them to display properly and there is still something not right with the theme but at least the widget links work now.

It’s been 24hrs and I’m still learning ;-)
http://www.themedellinblog.com/

Reply

Thanks for your help.
regrads.

Reply

thank you for the tips..it’s very usefull…

Reply

finally… now my two sidebars are working with widgets (it was only one sidebar)
thank you so much….

Reply

Great post. I’m started a new blog about hair styles. I have a similar kind of problem with my theme. I hope this will help me with the widgets part. I will try it out. Thanks for sharing the information.

Reply

Great info, thanks. I also have a blog which is a css gallery and I was having issues with widgets in the sidebar. This did the trick, thanks!

Reply

Leave a comment
Drive-By comments will be deleted! Like "Thanks for sharing", "Nice post", or any other text that doesn't contribute to the discussion. If you ask a very specific question about your particular WordPress theme's code, it will probably be deleted. I can fix your WordPress site but for a price. If you ask a question like "Why don't my blog work right", it will be deleted. If you ask a question about your WordPress site without a leaving a link to it, it will be deleted. The point is to ask questions and or comment on the the actual content of the post, and to please use some common sense. All comments are moderated. Thank you.

(required)

(required)