Fix WordPress Sidebar Widgets That Don’t Work

You may have come across a cool 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.



Share This AddThis Social Bookmark Button Sphinn Gregarious FeedFlare

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!


Tagged with ,


Related Posts





14 Responses to “Fix WordPress Sidebar Widgets That Don’t Work”

  1. 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>

  2. 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,

  3. 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.

  4. Still no luck, but thanks anyway!

  5. 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!

  6. 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

  7. 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! :-)

  8. Glad you got it fixed Tim!

  9. Thanks, and this is a great site, btw!

  10. 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

  11. 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

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

  13. 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

  14. 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.

Discussion Area - Leave a Comment

If you have a question about your blog please leave a link to it. Please don't ask questions like "Why don't my blog work right?" and expect an answer.

Two links or less are welcome, any more and your comment will be spammed! Nofollow has been disabled, all comments are moderated and will not appear until approved. Please submit only once.



XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Or just copy the example below and change your details.
Example - <a href="http://www.YourSite.com">Title Of Site</a>







Close
E-mail It