Custom Post Types In The Loop: Using `request` Instead Of `pre_get_posts`

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

I’m currently testing out a new version of my code to include custom post types in The Loop. So far, I haven’t found any functional differences. I’d like to do some things with post type archives and a possible `is_type()` function that would make my life easier when working with theme development, hence the change. I’m also trying out `any` instead of an array of post types.

Continue reading Custom Post Types In The Loop: Using `request` Instead Of `pre_get_posts`

Add taxonomy columns to admin Edit pages

I’m currently using custom post types and taxonomies extensively on this site, so it is very important to me to be able to see how I have catalogued a post, as well as being able to single out specific post types with a given taxonomy term while editing. The ideal place for this to happen is in the Admin Edit page.

The following set of functions grabs a list of available taxonomies for a given `post_type` and automatically adds columns to the Edit pages. This updated version does not have column information that disappears after using the Quick Edit AJAX on the Edit page. In addition, I’ve updated the taxonomy term links to actually work as filters on taxonomy and term.

Continue reading Add taxonomy columns to admin Edit pages

List a post type object’s terms and taxonomies

The native WordPress functions [`wp_get_object_taxonomies`](http://codex.wordpress.org/Function_Reference/get_object_taxonomies), [`wp_get_object_terms`](http://codex.wordpress.org/Function_Reference/wp_get_object_terms), and [`get_the_term_list`](http://codex.wordpress.org/Function_Reference/get_the_term_list) can be used to create a generic function to list of all taxonomies and terms of any custom post type.

Continue reading List a post type object’s terms and taxonomies

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

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 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`

Filter FeedWordPress syndicated posts into custom post types

I use [FeedWordPress](http://feedwordpress.radgeek.com/) to scrape my personal RSS feeds on various services into my WordPress blog as individual posts. Before the advent of [custom post types](http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress), I used categories and tags to separate these scraped posts from regular blog posts. However, it now seems more logical to add some of these posts as a custom post type.

Continue reading Filter FeedWordPress syndicated posts into custom post types