• Resolved mtuttle

    (@mtuttle)


    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'); ?>

    https://www.ads-software.com/extend/plugins/custom-post-type-ui/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Thread Starter mtuttle

    (@mtuttle)

    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?

    Thread Starter mtuttle

    (@mtuttle)

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

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Calling CPT by category’ is closed to new replies.