Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » Can you attach a CPT-onomy to Pages?

  • Resolved fosterbydesign


    First of all, thanks for putting together such a useful plug-in. It has really made a difference in how I work with WordPress.

    Here’s my scenario.

    I’ve created a custom post type called Resources (intended to hold things like white papers, datasheets, etc.). I’ve also created post types for Features, Partners, Solutions, and more.

    I edited the Features post type and checked Resources in the Attach to Post Types section. This means our marketing person can now upload a Resource, and while editing it they can “tag” which Features, Partners, Solutions pages it will show up on.

    (Note: obviously a little custom code used to display a “related resources” widget based on the current post type and what resources have been tagged to it).

    All good so far until I realized that Resources should show up on Pages too. Single the plug-in won’t let you edit the main post types, I don’t see a way to assign a CPT-onomy for Resources to Pages.

    I really could use this – can you provide any ideas on how to accomplish? I’m comfortable with a coding solution if you can point me in the right direction.

    Many thanks…


Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Rachel Cherry



    I’m glad you like CPT-onomies so much! It is definitely a labor of love.

    There is a programmatic way of registering CPT-onomies. Try this out:

    add_action( 'wp_loaded', 'my_website_register_cpt_onomy' );
    function my_website_register_cpt_onomy() {
       global $cpt_onomies_manager;
       if ( $cpt_onomies_manager ) {
          $cpt_onomies_manager->register_cpt_onomy( 'resources', 'page', array( 'restrict_user_capabilities' => array( 'administrator' ) ) );

    The last variable is an arguments array that you’ll probably want to customize. Check out the CPT-onomies documentation for more information.

    Thanks for the fast response!

    For my purposes (adding ‘page’ checkmarks while editing a ‘resource’ post), I needed to reverse ‘resources’ and ‘page’ in your register call.

    Now editing a resource works as expected. And that’s awesome.

    Small issue remains:

    When I use WP_Query to list all Resources that contain a ‘page’ with the current page slug name, it is returning all resources. This is ONLY happening on ‘page’ – the same exact code works for all other custom post types I’ve created.

    It sounds like the bug they fixed in WordPress 3.5:

    Any ideas?

    Here is a small snippet:

    global $post;
    $args = array (
    ‘posts_per_page’ => ‘-1’,
    ‘post_type’ => ‘resource’,
    ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’,
    ‘page’ => ‘my-test-page’
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();

    // Some posts (i.e. resources) come back with the ‘page’ taxonomy empty, despite the filter above – which should not be happening.
    Appreciate any pointers!

    OK, I tracked it down in case anyone else finds this useful.

    It appears that ‘page’ will not work as a “simple” taxonomy query.

    Instead of this:

    'page' => 'my-test-page'

    I used this:

    'tax_query' => array( array( 'taxonomy' => 'page','field' => 'slug', 'terms' => 'my-test-page'))

    Hope that helps!


    Plugin Author Rachel Cherry


    Awesome! Thanks Mark!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can you attach a CPT-onomy to Pages?’ is closed to new replies.