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.

Continue reading Adding A Custom Taxonomy Terms Widget To WordPress

Adding Custom Post Types To get_calendar() And The Calendar Widget

By default or design, the WordPress function `get_calendar()`[^1] does not handle post types other than `post`. I’ve updated it as the standalone function `ucc_get_calendar()` to allow it to accept a `$post_types` array; the included filter function `ucc_get_calendar_filter()` will allow for seamless integration via `functions.php` without requiring additional editing of Theme templates. (Note that the filter will also apply to the Calendar Widget’s output.)

Continue reading Adding Custom Post Types To get_calendar() And The Calendar Widget

Adding Custom Post Types To wp_get_archives()

Again with the custom post type extensions. This function lets the native WordPress `wp_get_archives()` [^1] [^2] know about public custom post types; just add it to the `functions.php` of your theme. Of note: the builtin `link` post type can be included at the `array_merge()` point; I just had no use for it.

Continue reading Adding Custom Post Types To wp_get_archives()

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 Shortcut Functions For Registering Taxonomies And Post Types In WordPress

Fix Post Editor Buttons character encoding mismatch

I love the [Post Editor Buttons](http://wordpress.org/extend/plugins/post-editor-buttons/) plugin for WordPress by [Oren Yomtov](http://orenyomtov.com/). It makes it easy to extend the Post Editor without needing to resort to hacking `quicktags.js`.

One tiny drawback: sometimes I have character entity mismatches. Quicktags for special characters, such as ‘é’ , ‘–‘ , ‘…’, work until the next time I add a quicktag via the PEB interface, when they are returned as ‘é’, ‘â��’, ‘â�¦’.

Continue reading Fix Post Editor Buttons character encoding mismatch

Add custom post type and taxonomy counts in the Right Now Dashboard widget

WordPress 3.0 adds custom post types to the Dashboard’s main navigation sidebar, but I wanted a quick overview of my custom post types and taxonomies in the Right Now widget, just like it currently has for Posts, Pages, Categories, and Tags. I used WordPress’s internal dashboard code to create similar entries for custom post types and taxonomies.

Continue reading Add custom post type and taxonomy counts in the Right Now Dashboard widget

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 Add custom post types to the Loop by adding an action to `pre_get_posts`