Categories

Meta

Adding A Custom Taxonomy Terms Widget To WordPress

The WordPress Categories Widget currently only handles the `category` taxonomy. I’ve modified it to allow the user to select a taxonomy, and tied in the Tag Cloud Widget code to give the user the choice of display formats: list, dropdown, and cloud. Multiple instances are possible, providing the user with an easy method for displaying links to user-built taxonomy terms.

`preg_replace_callback()` is used to fix the JavaScript for the dropdown menu; instead of generating the default `?query_var=value` format, it uses `get_term_link()` to generate the term URL.

8 thoughts on “Adding A Custom Taxonomy Terms Widget To WordPress”

Really useful widget thank you. You say multiple instances are possible and yes they do appear BUT only one works at a time (at least in my experience). I’ve used the code exactly as you have displayed above. Any ideas?

You will see that I have added two dropdowns; one for Business Directory i.e. custom taxonomy ‘business’ and another showing a dropdown of ‘post_tags’.

I tested this with just the first and it works fine but as soon as I add the second it stops functioning. Similarly, if I swap over and have Tags its fine then add Business and the first stops working.

I have installed your Plugin, and all is well. However, I must be missing something, because:
– I am always shown all posts from all custom taxonomies
– the selected c.t. does not remain selected (in the dropdown)

Contrary to that, I am trying to select one of the taxonomies and get shown only the posts with that taxomony.

OK, the first part seems to have solved itself – by some miracle (or amounts of coffee), I discovered the Taxonomy Terms Widget, and by including this, instead of custom menus, as used previously, only the selected custom taxonomy related posts are shown.

However, the second issue still prevails: as soon as I select a taxonomy, the drop-down box is reset upon displaying the list of posts.