WordPress Widgets
Posted in
First dog watch, 4 bells (6:21 pm)

I have written a couple of handy widgets for WordPress, and figure it's probably time I at least make them available to people. You can see each of these widgets running on this blog's sidebar right now.

I originally wrote these quite a while back, but just updated them and added the Tags drop-down to go with WordPress's 2.3 release.

If you get the files individually, rename them to a .php extension.

Upload the files to your wp-content/plugins/widgets directory. Activate them in the Plugins section and then you can move them around in your widget-aware theme under Presentation / Widgets. Enjoy.

If you examine the code, each drop-down widget has it's own CSS block-level div id that you can customize in your theme's style.css, if you feel so inclined.

Note: With the release of WordPress 2.5, the Archives and Categories have been deprecated. These drop-down controls are now built in to WordPress. There is a tag cloud available, but not a drop-down control, so I will continue to maintain it.

Also, given that WordPress 2.5's links continue to not adhere to XHTML 1.0 Strict standards, I have made my "strict links" widget available. Since the get_links() has also been deprecated, this file uses the new wp_list_bookmarks() call. You will probably need to edit the file for it to work on your site.

strict_links.txt. Rename as .php and dump in your widgets directory as usual.

WordPress Miscellanea

I've run across several small but annoying "features" WordPress has that I'd like to fix up. First off is the smart quotes, where WordPress converts single- and double-quote characters into the fancy curved quotes that look typographically nicer, but are a pain when quoting code.

So to fix it, just add the following line (or lines) to your functions.php file in your theme directory:

The second is the annoying XHTML-Strict compliant Search box. For some reason, WordPress developers like to break XHTML-Strict guidelines when it would be easy to simply follow them. You need to wrap the label tag with a div to comply. Fortunately, all you need is another file in your theme directory called searchform.php. It should contain:

<form method="get" id="searchform" action="<?php echo get_option('home'); ?>">
    <div>
        <label class="hidden" for="s">Search for:</label>
        <input type="text" value="" name="s" id="s" />
        <input type="submit" id="searchsubmit" value="Search" />
    </div>
</form>
6 Comments »

6 Responses to “WordPress Widgets”

  1. Bobby says:

    I've used Drop-down Tags with my blog. I think you the only one who made this drop-down tags plugin. Very nice indeed.
    Thank you very much 🙂

  2. Webmonster says:

    You're welcome! I'm glad it's been helpful to you and hope other people find it useful as well.

  3. kerman says:

    hi!

    Very nice widget, i want to know how i can customize the tag list that is shown in the dropdown. If i want to show only a certain tags...is there a way to do it??

    Thanks!!

  4. Scurvy Jake says:

    Kerman-

    I think the best thing to do would be to modify the SQL query, although you could alter the foreach() section as well.

    I would add to the WHERE clause:
    AND t.name IN ('tag1', 'tag2', 'tag3')

    listing the tags I wanted to display.

  5. Nick says:

    Excellent! I had been looking for just this, and was worried I was going to have to build it myself! Thanks for this, you have just saved me a lot of time!

  6. Scurvy Jake says:

    You're welcome, thanks for stopping by!