Unique post category/term

Standard

In WordPress, we can set multiple categories/terms for a post. This is true for both hierarchical taxonomies (ex: category) and non-hierarchical taxonomies (ex: post_tag). However, on a project I’ve worked on, the client wanted me to make the category metabox to use radio inputs (exactly like WordPress’ new post format feature) instead of checkboxes to prevent the editor from setting multiple categories for the post (s)he writes. This request forced me :) to come up with a solution. I was also inspired by Justin Tadlock’s idea on using a taxonomy for theme layout. Here’s my solution in hope it could be useful for others.
Continue reading

WordPress Attachment Category/Terms

Standard

I was working on a photography site project for a dear friend of mine, Virda, and it requires me to set categories/terms for the attachment images. By default, an attachment post will inherit its parent terms, but, what if we only need to pull attachments which have certain terms? Querying their parents and then filtering the result will surely need more time and resources don’t you think? Besides, we won’t have the freedom to set the attachments’ terms without modifying their parent posts.
Continue reading

Add Custom Class(es) to ANY Widget

Standard

WordPress has a powerful API for creating, configuring and displaying widgets, but one thing I really need is the ability to add custom class(es) to the widgets. Every widget should usually come with its own classname, which will be printed when the sidebar is being displayed. So, assuming you’ve used the correct method for registering sidebar, you can add these following functions to your theme/plugin to provide the user the ability to add custom class(es) to the widgets.
Continue reading