Category Archives: Code

Shortcut Functions For Registering Taxonomies And Post Types In WordPress

After I had created several custom taxonomies and post types, adding more by directly calling the register_taxonomy[^1] and register_post_type[^2] functions seemed like a huge waste of space. The following functions create a shortcut for registering taxonomies and custom post types in WordPress; just choose whether you’d like the taxonomy to resemble Post Tags or Categories when calling the function ucc_register_taxonomy, and specify an array of taxonomies for ucc_register_post_type.

Continue reading

Add custom post types to the Loop by adding an action to `pre_get_posts`

[deprecated permalink="http://uncommoncontent.com/2012/01/28/add-custom-post-types-to-the-loop"]

I wrote this function to allow me to use custom post types in my blog without having to fine-tune each template for their inclusion. It checks the query to see if post_type is set; if it is not set (as it would be on a specific post type’s archive page), it includes all public post types.

Continue reading

Adding Taxonomy Columns To Admin Edit Page For Custom Post Types In WordPress

[deprecated slug="adding-taxonomy-columns-to-admin-edit-pages-in-wordpress"]

I’ve been playing with custom post types and taxonomies for organizing all things not post and I wanted to customize my admin edit screens for each new custom post type. Navjot Singh’s tutorial[^1] and this thread on Theme Hybrid’s forums[^2] both provide an introduction to adding taxonomy columns. However, I am lazy and don’t like hardcoding in variables each time I add a custom post type or new taxonomy.

The following set of functions grabs a list of available taxonomies for a given post_type and automatically adds columns to the appropriate admin pages, without the need to hardcode each post type to taxonomy relationships.

Continue reading