WordPress.org

Ready to get started?Download WordPress

Plugin Directory

CPT-onomies: Using Custom Post Types as Taxonomies

Use your custom post types as taxonomies. Create powerful relationships between your posts and, therefore, powerful content.

Why does CPT-onomies not work with all of the WordPress taxonomy functions?

Good question. While CPT-onomies strives to mimic taxonomy functionality as much as possible, CPT-onomies are not stored in the database in the same manner as taxonomies. The simplest answer to "Why not?" is that I believe my current method of "not duplicating post information to resave as taxonomy information" is in the best all-around interest of not only my plugin, but also your web site. With that said, I am constantly searching for new ways to "hook" into WordPress to improve CPT-onomy/taxonomy integration and, when impossible, will continue to provide workarounds.

How do I associate a CPT-onomy term with it's matching post?

Another good question, with a very simple answer: the term ID. CPT-onomies return the same information as taxonomies, including a term ID. A CPT-onomy term's term ID is the same as its post's post ID.

I'm not able to save my custom post type because the page keeps telling me "That post type name already exists."

This is a jQuery "bug" that only seems to plague a few. I've noticed that this validation standstill will occur if you have any text printed outside the <body> element on your page. If that's not the case, and the problem still lingers after you've upgraded to version 1.1, you can dequeue the validation script by placing the following code in your functions.php file:

<?php
add_action( 'admin_head', 'my_website_admin_head' );
function my_website_admin_head() {
    wp_dequeue_script( 'custom-post-type-onomies-admin-options-validate' );
}
?>

When assigning my CPT-onomy terms, I see a checklist but I would like to use the autocomplete box (or a select dropdown).

As of version 1.3, you can change the format for your meta boxes via the settings page! The following filter still works, though, so feel free to use as you please. It will overwrite the settings.

If you have a hierarchical CPT-onomy, the default selection format is a checklist. But if you would rather use the autocomplete box, or a select dropdown, CPT-onomies allows you to hook into the meta box (via a filter) and overwrite the default selection format.

Here's an example of the filter. More information, check out the "Help" tab in the CPT-onomies settings or visit the FAQ .

<?php
add_filter( 'custom_post_type_onomies_meta_box_format', 'my_website_custom_post_type_onomies_meta_box_format', 1, 3 );
function my_website_custom_post_type_onomies_meta_box_format( $format, $taxonomy, $post_type ) {
   // when editing a post with the post type 'movies',
   // we want to assign the 'actors' CPT-onomy terms with an autocomplete box
   if ( $post_type == 'movies' && $taxonomy == 'actors' )
      return 'autocomplete';
   // no matter the post type, we want to assign the 'actors' CPT-onomy terms with a select dropdown
   elseif ( $taxonomy == 'actors' )
      return 'dropdown';
   // no matter the post type, we want to assign the 'directors' CPT-onomy terms with a checklist
   elseif ( $taxonomy == 'directors' )
      return 'checklist';
   // WordPress filters must always return a value
   return $format;
}
?>

I added support for "Thumbnail" to my custom post type, but the "Featured Image" box does not show up

You also have to add theme support for post thumbnails to your functions.php file:

<?php add_theme_support( 'post-thumbnails' ); ?>

If FAQ didn't cover your problem, refer to the following resources:

Requires: 3.1 or higher
Compatible up to: 3.7.1
Last Updated: 2013-11-8
Downloads: 17,391

Ratings

5 stars
5 out of 5 stars

Support

3 of 6 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

0,1,0
100,2,2 100,3,3 100,2,2 100,1,1
100,1,1 100,2,2
100,2,2 100,1,1
100,4,4
100,3,3
0,1,0 50,2,1
100,2,2 100,2,2
100,1,1
100,3,3
100,1,1
100,2,2
100,1,1
100,1,1