Custom Post Type UI
[resolved] Calling CPT by category (5 posts)

  1. mtuttle
    Posted 3 years ago #

    Ok, I setup a CPT and added the category capability to it when I set it up. Then I added several categories and I want to call a different category on one page and another category on another page.

    Here's my code, which doesn't work. Any help is appreciated.

    <?php $cpt = get_post_meta($post->ID, "my_meta_box_select", true); ?>
      <?php $temp = $wp_query;
    	$wp_query= null;
    	$wp_query = new WP_Query(); ?>
      <?php $wp_query->query("post_type= '.$cpt.'&paged=".$paged.'&showposts=5&cat=upcoming-meetings'); ?>


  2. Michael Beckwith
    Plugin Author

    Posted 3 years ago #

    What's the my_meta_box_select part for? The post type isn't going to be stored as meta data for the post in the post type. The value you want in place of $cpt is the first field you filled in, at the top, with the UI plugin.

  3. mtuttle
    Posted 3 years ago #

    Well, the meta_box_select was being used on a page template I setup that would allow a client to create a new CPT, add a new page selecting said template, and then use a drop down in a meta box that listed all the registered post types to display post from only the CPT selected. I got it to work and I think it's helpful for people who can't code their own sites, but can use the dashboard.

    I am wondering if you know of a method to add a metabox to all the CPT's created by CPT UI?

  4. mtuttle
    Posted 3 years ago #

    Oh yeah, any interest in seeing what I setup? Might be useful to include with the plugin so others can use it as well.

  5. Michael Beckwith
    Plugin Author

    Posted 3 years ago #

    I'd probably just create an array of the CPTs that you've registered and then do the metabox registration in a foreach loop that iterates over the array.

    You can post the code used, but our plans for the plugin are to do a few things and do them well, which is registering the post types and taxonomies. Any bells and whistles that users want to add will be achieved the same way that tutorials, around the web, describe.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Post Type UI
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.