WordPress.org

Forums

How to widgetize this sidebar? (25 posts)

  1. Remex
    Member
    Posted 8 years ago #

    Just wondering whether it can be widgetized, if the answer is yes, what code should I adding to the code in functions.php?

    This is the sidebarcode:

    <div id="categories">
    <h3><span>Categories</span></h3>

    <ul>
    <?php wp_list_cats('sort_column=name&hide_empty=0&hierarchical=0'); ?>
    </ul>
    </div>

    <div id="archives">
    <h3><span>Archives</span></h3>

    <ul>
    <?php wp_get_archives('type=monthly'); ?>
    </ul>
    </div>

  2. jimsolt
    Member
    Posted 8 years ago #

    Well, I don't recognize that code -- mine's different -- but the issue is the same, so I'll piggy back if I may.
    WP 2.0.4, Default. I have downloaded, unzipped, and uploaded files to what should be the proper WP files -- according to readme that came with download. I have also activated all I can find to activate, yet NOTHING HAPPENS. My conclusion is pretty much the same as Remex -- I need to widgetize. I have from Automattic a suggested 4 line code for my sidebar, but I can't figure out where in the sidebar code I should put it.
    Like many of the problems I am experiencing with WP, it seems my version (the latest one) is newer than most of the fixes given in the Forums. Consequently I can't compare my files with the examples used in the instructions.
    I have emailed a similar message to Automattic, but thus far no response from them. Their web site looks like it would be perfect for modifying another version of WP, but doesn't look at all familiar to me.
    Help appreciated. Thanks.

  3. vkaryl
    Member
    Posted 8 years ago #

    Download the widgets plugin from http://automattic.com/code/widgets/

    Uncompress the distro. Copy the classic and default folders to your wp-content/themes folder (which will overwrite ONLY the sidebar.php file, and add the functions.php file). Copy everything else to wp-content/plugins/widgets/ (in that folder you should have a scriptaculous folder, a README file, rss.png graphic and widgets.php file).

    In the sidebar.php file for your theme, find the opening nested-list ul tag, and insert immediately after it and before the first opening li tag:

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

    Scroll down to just before the closing ul tag, and insert:

    <?php endif; ?>

    Copy the functions.php file from the classic folder preferably (unless you're using the vanilla default theme) into your theme folder.

    Now, upload the new sidebar.php file and the functions.php file to your wp-content/themes/yourtheme folder online. Upload the widgets folder to wp-content/plugins.

    Access wp-admin/plugins - activate widgets. You should see the default widgets in the sidebar widgets tab under the presentation tab.

  4. jimsolt
    Member
    Posted 8 years ago #

    vkaryl,
    I'm doing what you suggest with no luck. When I first added the code you suggest, I got an error about a php end not expected, but I have corrected that (not sure how - perhaps typing error)and now the blog loads alright, but still looks exactly like it did before I downloaded the widgets, activated them, and added your suggested code. In my dashboard>themes there is no "widget".
    Though php is not my native language, it looks to me as though the <?php if ( function_exists . . . line is trying to find the "function" and can't, so as designed it goes on with the previous code.
    Even if I'm right about this, I don't know how to solve the problem, so help is still needed AND appreciated.

  5. vkaryl
    Member
    Posted 8 years ago #

    jimsolt: you did activate the widget plugin, right? I failed to include that instruction above, sorry.

  6. jimsolt
    Member
    Posted 8 years ago #

    vkaryl: Yes I have activated 3 plugins as a result of this attempt to widgetize. They are del.icio.us, Google search, and sidebar widget. The last says it will add sidebar widgets under presentation. Under my Presentation I have only 3 choices, Themes, Theme editor, and Header Image and Color --- No Widgets.

  7. vkaryl
    Member
    Posted 8 years ago #

    Okay, just checkin'.... best to be on the same page as it were.

    What theme are you using? Some themes seem to have a problem interfacing with widgets.

  8. jimsolt
    Member
    Posted 8 years ago #

    Using Default Theme on WP 2.0.4.

  9. Remex
    Member
    Posted 8 years ago #

    Thanks for all your kindly responses.

    jimsolt, so we have the same problem.

    Viper007Bond, yes, i have read about the article several times, but the "My sidebar isn’t a list. What do I do?" paragraph didn't perfectly help me widgetizing my theme. I am a newbie to PHP code and don't know what code should adding into the "functions.php" to fix.

  10. michaelbb
    Member
    Posted 8 years ago #

    He's not alone here, I have downloaded themes that say there fully widget compatible or ready, and than when you go to modify / add widgets, you dont get what you expect.

  11. jimsolt
    Member
    Posted 8 years ago #

    Anyone? Does anyone have or know of someone who has a Default Theme on WP 2.0.4 that has been widgetized? Or is my time better spent on saving the world?

  12. vkaryl
    Member
    Posted 8 years ago #

    All you should have to do with the default theme is copy the default folder from the widget download over the default folder you already have. It has the appropriate changes in the sidebar.php file and the appropriate functions.php file.

    I realize you may have tried that already, but I just yesterday did this for a client with the default theme. It worked fine, she's blogging away with widgets in place. I can't give you a link, she's not ready for "prime time" I guess - I emailed her earlier, just got a reply asking that I not release the URL.

    I'm sorry, I just don't know what else to say. If you want to give me a day or so, I'll put one up on one of my own sandboxes and provide a link, but I doubt I'll have time before tomorrow afternoon at the earliest.

  13. CricketPond
    Member
    Posted 8 years ago #

    Must be something in the air today... I, too, am trying to widgetize. I'm using a widget-ready theme according to WP list--Blue Memories. http://www.karenshanley.com/blog

    I downloaded and dragged and dropped widget folder into contents/plugins folder. Activated sidebar widgets on dashboard and nothing--.

    Any other thoughts?

  14. KatGirl
    Member
    Posted 8 years ago #

    Okay, so there is no mistake.

    1) Download the widgets plugin

    2) unzip and DOUBLE CHECK that there's no duplicating yellow files - sometimes this happens. If this is the case, the plugin cannot be read correctly.

    3) Upload the Widgets folder containing the PLUGIN to your plugins folder ie: wp-content/plugins/widgets

    4) activate the plugin. If necessary, hit ctrl+F5 for hard refresh. You should see a new tab within the Presentation admin area. "Sidebar Widgets".

    5) Upload Default sidebar to the Default Theme Folder. Your FTP program SHOULD ask you if you want to overwrite your current sidebar. Click yes - only if you haven't modified the sidebar.

    6) Upload Classic sidebar to the Classic Theme folder. Your FTP program should ask you if you want to overwrite your sidebar. Click yes if you haven't modified the sidebar.

    7) Upload functions.php to your CURRENT THEME folder
    ie: wp-content/themes/default OR
    ie: wp-content/themes/classic

    8) Go to Presentation/Themes/Sidebar Widgets and start playing.

    CAVEATS:
    From the instructions above, the widget will NOT work if you are using your own theme. Uploading both Default and Classic sidebar.php respectively will only introduce widgets to those themes. It will NOT introduce widgets to your current theme, unless your current theme is indeed Classic or Default.

    YOUR THEME
    1) upload the plugin as mentioned above - double check that there's no duplicating folder.

    2) activate the plugin

    3) if necessary hit hard refresh

    4) Go to Presentation/themes. You should see a new admin page offering Sidebar Widgets

    5) go to Presentation/theme editor

    6) Select YOUR CURRENT THEME (Not default or Classic, in this case)

    6) Insert this code into the sidebar where you want the widgets to work - NOT APPEAR. Notice the difference in wording?

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
    <?php endif; ?>
    7) save the sidebar file

    8) Go to Presentation/Themes/Sidebar Widgets and start playing. What you drop and drag here, will APPEAR in your sidebar, once you save your playing.

    Hope that clears up any confusion

  15. CricketPond
    Member
    Posted 8 years ago #

    Wow, KatGirl. A big thanks! Off to follow your directions.

  16. KatGirl
    Member
    Posted 8 years ago #

    For those trying to impliment a different sidebar into their theme with widgets, this is what's inside my functions.php which is exists inside my CURRENT THEME folder.

    I use TWO sidebars - sidebar.php and sidebar1.php (actually, I use more than that, but for this purpose this exercise will do)

    FUNCTIONS.PHP
    <?php
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    'name'=>'sidebar',
    ));
    register_sidebar(array(
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    'name'=>'sidebar1',
    ));
    }
    ?
    >

    hope that helps too.

    you can add as many additional functions as you like, depending on how many sidebars you use and what you call them. Don't forget to change the name to reflect the name of your additional sidebar.

    EDIT: sorry, forgot to add that my sidebar ISN'T a standard list. ie:
    <li id="wp-pages">Pages
    <li>link 1</li>
    <li>link 2</li>
    </li></ul>
    </ul>

    That should help the posters above who mentioned that their sidebar wasn't a list, either.

  17. CricketPond
    Member
    Posted 8 years ago #

    KatGirl, I got as far as getting everything where it should be. But I'm confused on your directions:

    ***6) Insert this code into the sidebar where you want the widgets to work - NOT APPEAR. Notice the difference in wording?

    Where am I supposed to be looking to see the difference in wording. Insert what code into sidebar? The below? I did that. If you're referring to something else, I don't understand. I also don't understand "NOT APPEAR" Am I supposed to put that somewhere?

    ***<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
    <?php endif; ?> "

    Is this supposed to be cut and pasted where it says:

    <?php /* if the Sidebar Widgets plugin is enabled */ if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

    Obviously, I don't know my arse from my elbow here.
    Thanks for your help and patience.

  18. CricketPond
    Member
    Posted 8 years ago #

    I also tried cutting and pasting your code into my functions php. I'm still not able to drag and drop widgets into the sidebar. But then why would that work when I don't have the sidebar php working yet. Sigh. A desperate act by a tired woman.

  19. KatGirl
    Member
    Posted 8 years ago #

    Hi Karensh1

    Take a deep breath... Okay. Maybe my instructions were a little confusing.

    All you need to do is insert the code into your sidebar where you want the widgets to work/appear. I just wanted those to understand that while insertion of code into the sidebar calls the widgets into play, NOTHING will show unless something has been dropped and dragged into a sidebar box within the Presentation/Sidebar Widgets Admin Page.

    Does that make sense?

    You should copy & paste the code to a text file first, and save to desk top. You shouldn't copy & paste anything from a webpage directly into wordpress software as it tends to introduces cruft.

    Here's the code:
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>

    <?php endif; ?>

    I noticed you provided an already existing widgets code from your sidebar template.
    <?php /* if the Sidebar Widgets plugin is enabled */ if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

    If you have only one sidebar, try removing the 1 from within the brackets. Don't remove the brackets themselves.

    If you have a sidebar that's called something else, you'll need to do this:

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('articles-sidebar') ) : else : ?>
    <?php endif; ?>

    See where I've added the name of my new sidebar inside the brackets?

    You mention that you're still unable to drop and drag stuff into your widgets. Do you have a new page within Presentation/Themes/Sidebar Widgets?

    Can you see a list of widgets you can drop and drag? Like links? Categories? Pages? Calendar? Stuff like that?

    Do you have directly above those choices, a large-ish box that is called Sidebar?

    EDIT: When I said NOT APPEAR. See the difference in wording?, I was indicating that nothing will show in your webpage/sidebar unless, and until, you actually drop and drag stuff into the nominated sidebar box that exists within the Sidebar Widgets Admin Page. Hope that clears up any confusion.

  20. CricketPond
    Member
    Posted 8 years ago #

    Hi KatGirl. First, thank you so much for your time and effort. It's much appreciated.

    I tried putting in your code and still nothing.

    Yes, I the sidebar page is there and I can see the sidebar and the widgets. I just can't drag and drop the widgets.

    I'm so tired now, I'm cross-eyed. So, if you're able to untangle the mystery, I'll try again first thing in the morning.

    Nominating you for sainthood.
    Karen

  21. KatGirl
    Member
    Posted 8 years ago #

    Okay, my last question before you nod off. What browser are you using to work the back end?

    Do you use FF? I've noticed the IE tends to be quirky.

    Just a thought. And don't despair. You'll get it working. You're troubleshooting the problem with dedication.

    I admire that. :)

  22. CricketPond
    Member
    Posted 8 years ago #

    Sorry, I nodded off immediately after my last post. I'm an early riser, which also makes me early to bed.

    Yes, I use Firefox.

    I also tried installing another plugin, AdminDropMenues 2.o, to see if I could get something else working. No go there either.

    Before I closed out last night, I put everything back the way it was to get a fresh start this morning.

    Hmm. serious deja vu here. Anyway, thanks for the supportive words. They do help.

  23. CricketPond
    Member
    Posted 8 years ago #

    P.S. There is often a single file page php with each plugin that stands outside the folder for that plugin. I've assumed that should go in the content/plugin folder as well. Does it need to go into the specific folder for that plugin or just at the bottom of the contents/plugin folder?

  24. CricketPond
    Member
    Posted 8 years ago #

    WooHoo--and Duh

    KatGirl, I printed out all your posts and went through each step again. WooHoo!!! I got the sidebar widget working!!!
    And Duh on me, because I did check to see if there was a double widget folder, but didn't think that one widget folder being a subfolder of the first counted as a duplicate. Anyway, got rid of one of the folders--and Voila!!!

    It's amazing what a nite's sleep does to get the ol' brain working again.

    Many, many, many thanks!!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.