Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there an easy way to group custom post types on the admin sidebar menu?

The reason i ask is because i want to try to accomplish the following:

I've created a custom post type titled "Latest News" it's nothing more than a block area that will have a link that links out to another website so there are only two custom fields in this post type "URL" and "Headline Text".

However I will use this custom post type on 27 other different pages and this would not even be an issue if i could just use the same content on all of those 27 pages. Instead there needs to be custom news for each of those 27 pages.

Here's my noob approach:

I will create 27 different custom post types that have a unique description but ALL have the exact same custom fields which i'll have to create repeatedly as well for each of the 27 pages just so that i can link them to their specific custom post type and include that unique description within the specific page that the news will be relevant to.

I know it's a super bloated way to do things and WordPress probably has a better way to do this that requires knowing "if else" statements within custom functions. While i'm not afraid to try that i don't know very well how to do that but am willing to work it.

So as you can tell creating 27 custom post types just for this "Latest News" block area will make my Admin menu so long, hence the title of this question on how to group CPT's in the admin sidebar menu, but that's not really what i'm after.

Not to mention that if i can't find a better way to do this i'll end up doing the same thing for 10 other custom post types i need to make that will also go on 27 pages that are all using the same template but require unique content. That alone would make a sidebar admin menu with 297 custom post types and that's just insane.

Someone slap me and tell me what i'm doing wrong.

Thanks.

 <?php

    $args = array(
            'post_type' => 'latest_news',
            'tax_query' => array(
                   'taxonomy' => 'news',
                   'field' => 'slug'
                   )
    );

    $the_query = new WP_Query( $args );

    ?>

    <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>


      <?php the_field( 'url_latest_news' ); ?>


    <?php endwhile; else: ?>


    <?php endif; ?>
share|improve this question
    
Why not one CPT and and a custom taxonomy to differentiate the content for the 27 different pages? –  s_ha_dum Sep 20 '13 at 14:16
    
@s_ha_dum ok this is interesting to me i'll research how custom taxonomies work. I'm also wondering why, when a new Field Group is created, don't they have unique ID"s to them so that you can can call on that specific ID or set of ID's from any given page. When i research taxonomies in relation to Field Groups how do they associate? For example i'm using ACF (Advanced Custom Fields) plugin and i'll look to see if there wan an option to include a taxonomy but otherwise how would you go about creating the taxonomies for different pages that you would want to call a certain field group from? –  MARS Sep 20 '13 at 14:22
    
does that make sense? Wait i just remember something about taxonomies when i created the Custom Post Type using the Custom Post Type UI plugin. I'll investigate that and see if that would help because it's still unclear to me how taxonomies work at the Field Group level because i'm thinking if taxonomies are only available at the custom post type level wouldn't i still have to create 27 custom post types each with their own taxonomy or am i missing the point of what Taxonomies are all about? Anyways off to research, thanks for your guidance. –  MARS Sep 20 '13 at 14:26
    
Sorry, what does an ACF Field Group have to do with the admin menu on the left? I think you are missing the point though. Maybe I should just sketch out an answer... –  s_ha_dum Sep 20 '13 at 14:46
    
The ACF Field Group Doesn't have really anything to do with the admin menu on the left. As i'm sure you know, this plugin is used to create the Field Groups for your Custom Post Types. The Custom Post Types on the other hand do obviously created a new admin menu item for whatever post type you created and it was this in particular i feared would happen due to my lack of understanding how content is dynamically generated for 27 pages that all will use the template (when i make it) but require their own unique set of content. –  MARS Sep 20 '13 at 19:16
add comment

1 Answer

If I understand what you are doing, and I may not, I would not do this with multiple Custom Post types, much less 27 of them.

I would...

  1. Create a single Custom Post Type for this "Latest News" data.
  2. Create a Custom Taxonomy to sort the data. This taxonomy would have 27 terms to correspond to, and serve instead of, the CPTs that you are thinking about making.
  3. Create a theme template or templates to handle the data

To make this work, you would create a new post in your CPT and mark the appropriate term in your custom taxonomy. The template(s) you create in the theme would then display posts from the CPT according to a taxonomy argument-- that is display posts based on the term chosen.

share|improve this answer
    
i answered your other question before reading this answer. This is cool i'm going to mull it over in my head and work one example out and see how i do. Great stuff though, thank you. –  MARS Sep 20 '13 at 19:20
    
ok i'm baby-stepping this to make every step concrete. I created the CPT for Latest News. I created a custom Taxonomy titled "Homepage News" to identify it's relevance. Then I added a Latest News and inside of that "post" there is now a widget on the sidebar of the CPT i created titled "Homepage News" with an input field and i'm not quite sure what to do with that, are those for tags? –  MARS Sep 20 '13 at 19:28
    
Now regarding the template point. I will be creating a template titled "Single Neighborhood" that will also have this "Latest News" CPT in the same spot that i have it on the homepage. This new template will be used 27 times for different neighborhoods (hence the reason the news has to be unique to each hood). –  MARS Sep 20 '13 at 19:35
    
Now when i create this template the "taxonomy argument" you refer to I assume is some kind of array? And if so would that mean that every page i create (because there will have to be 27 pages totaling all the hoods) using the template "Single Neighborhood" will have to have some kind of taxonomy identifier (which i haven't figured out how that works yet) in order for the argument to know which content to display for that neighborhood, is that how it works? –  MARS Sep 20 '13 at 19:36
    
that is to say that the loop inside of this "Single Neighborhood" template will have to have an array with some parameter (i haven't figured out or know that exists yet) that would display the content based on the matching taxonomy of that particular page? Sorry for my long-windedness. –  MARS Sep 20 '13 at 19:38
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.