Programming: Category Archive (Page 7)

Posts related to software development

Monday, December 24, 2007
  Daniel’s DropDowns 2.0.1 - WordPress Plug-In

I have released version 2.0.1 of Daniel's DropDowns, the WordPress plug-in that provides category and archive dropdown template tags. It is available on its page at the WordPress Plug-In Directory.

This was a minor change - the auto-navigating lists added in version 2 needed a slight tweak. There wasn't a “select category” entry, so one could not navigate to the first item in the list without going somewhere else first. The category dropdown now has this entry, and is consistent with the archive dropdown.

Enjoy!

(UPDATE: This plug-in is inactive, as its functionality is now part of WordPress core.)

Categorized under
Tagged , , , ,

Sunday, December 23, 2007
  Daniel’s DropDowns 2 - WordPress Plug-In

I have released version 2 of my category and archive drop-down plug-in for WordPress. It is hosted at the WordPress Plug-In Directory - you can go get it there. Following are a few of the changes that were made.

  • Both tags now have only 2 parameters - the type of navigation and the text for the link or button. For navigation type, ‘button’ remains the default, and ‘link’ is still available. However, a third option of ‘auto’ has been added, which will render the list as an auto-navigating select box.
  • The CSS parameters for the select and button elements were dropped. How these elements can be specified using CSS is detail in the top-of-plugin comments, along with an example.
  • The usage examples in the comments now have an example of how to put the tag in a template in such a way that, if the plug-in is disabled, the template will still render. This could be done with 1.0, but I didn't give an example.
  • I added PHP Documentor-style comments to both functions.

Let me know if you have any problems with it, or any ideas for other behavior. Enjoy!

(UPDATE: This plug-in is inactive, as its functionality is now part of WordPress core.)

Categorized under
Tagged , , , ,

Sunday, November 25, 2007
  Adding Tags to a WordPress Theme

WordPress 2.3 introduced tags, but unless you're using the default theme, your theme (like mine) probably didn't support them. Nowhere did I find a good example of how to add tags to your theme. Then, I was playing around with the theme switcher on my personal blog, and discovered that the default theme had tag support. I looked at it, and it was amazingly simple.

There is a new template tag called ...drumroll… the_tags. It takes three parameters: how to begin the list, how to separate each tag, and how to end the list. The tag does not do any output if a post hasn't been tagged, so it can safely sit in your theme until you need it to be active.

Here's how I did it in my personal blog.

<?php the_tags('<div class="tags">Tags » ', ' • ', '</div>'); ?>

Of course, you could also do it using an unordered list…

<?php the_tags('Tags<ul class="tags"><li>', '</li><li>', '</li></ul>'); ?>

Drop some styling for the “tags” class in your theme's CSS, and you're good to go!

(Well, not quite. You'll want to make sure to make the same change in your main index template, single post template, and archive template, so that the tags appear no matter how the user got to the post.)

Categorized under
Tagged , , ,

Tuesday, October 2, 2007
  Daniel’s DropDowns 1.0 - WordPress Plug-In

I've created a plug-in that I'm now using on my personal site to provide the category and archive drop-down lists. It's called “Daniel's DropDowns”, and it will create drop-downs with either a link or a button to go to the selection in the drop-down, and a CSS class can be specified for the button and the drop-down box.

daniels_dropdowns.txt - Daniel's DropDowns 1.0 (UPDATE: This functionality is now part of WordPress core.)

To install it, download the file, rename it “daniels_dropdowns.php”, and upload it to your /wp-content/plugins directory. Then, enable it, and add the template tags to your theme. (The documentation at the top of the file lists all the template tags provided, and the options that can be passed to them.)

Categorized under
Tagged , , ,

Tuesday, September 25, 2007
  HCSB Verse of the Day 1.0 - WordPress Plug-In

I have used a hack in the theme of my personal site for a while to obtain the “Verse of the Day” in the Holman Christian Standard Bible (HCSB) version. With things that I've learned about plug-ins, I decided to take a stab at creating a plug-in to do this work. That way, if I changed themes, I wouldn't have to hack the new one they way I've hacked the current one.

The fruits of my labor is the new HCSB Verse of the Day plug-in for WordPress. It uses the reference from BibleGateway.com, then gets the text from their regular website. (They do not provide the service, citing copyright restrictions.) How to use the plug-in, along with my justification on copyright grounds, is in the top of the file's comments. If they're not clear, certainly post comments here and I'll address them. (I do plan to submit the plug-in to WordPress.org - but, they require a specific README file format that it will take me a bit to put together.)

votd_hcsb.txt - HCSB Verse of the Day 1.0 (UPDATE: It is in the plugin directory now.)

To install it, download the file, rename it “votd_hcsb.php”, and upload it to your /wp-content/plugins directory. Then, enable it, and add the template tags to your theme - that's it!

Categorized under
Tagged , , ,

Monday, August 6, 2007
  Incorporating an Akismet Counter into a WordPress Theme

Akismet is, by far, the most popular anti-spam plug-in for WordPress. (It comes bundled with the download, so that gets it market share. But, it's also very, very good.) It comes with a counter that can be put into a WordPress theme. It's attractive, but its light blue color may not integrate well into a given theme.

I went digging around in the source code, and found the line that actually pulls the count from the database. Using this parameter, I was able to integrate a spam count into the sidebar that has a look consistent with the rest of the site.

Here's the code that's in use on the theme on this site.

<li id="spamstats">
  <h2><?php _e('Akismet-Eaten Spam:'); ?></h2>
  <ul>
    <li><a href="//akismet.com"><?php
      echo(number_format(get_option("akismet_spam_count"))); ?>
      and counting...</a></li>
  </ul>
</li>

Of course, line 5 is the important one - that's how to get the number, formatted for whatever locale the server is set up for. (On my personal blog, the number is up over 1,400!)

Categorized under
Tagged , , , ,