0

I understand I can associate CPTs in submenus like so: Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu

However, my question is if I have one CPT, let's say for a ECommerce type of post type, so it would be Orders as the post type and I have orders with different meta information in their post_meta such as approved, pending, denied, etc. can I have submenus which load an admin table using WP_List_Table of a subset of the custom post type, that is based on their meta data.

So the admin menu looks like

-Orders CPT (Show All Orders in List)
--Approved Orders (Show only Approved Orders in List)
--Denied Orders (Show only Denied Orders in List)

etc.

The reason I am asking is because at first I was doing add_menu() or add_submenu() with a custom callback to generate the HTML, but then I realized this was unnecessary as I was ending up recreating the default WP_List_Table, but I don't want multiple CPTs when they are all really subsets of the same CPT differentiated by meta-data... is this possible or should I do different CPTs somehow?

0

I would suggest you add two custom links to your CPT submenu, related:

How to Add a Sub Menu Page to a Custom Post Type?

The callback function of these submenu pages could then display your subset of custom post types.

  • Yes but, I'm aware of this callback, my problem is I don't want to have to recreate the list of posts that fall under the CPT, I want the default display/view but only of the subset of CPTs with certain meta data. – Summer Developer Sep 16 '18 at 2:12
  • In this case, why not just extend the filter functionality of your CPT admin screen? As an entry point, you could use this: wordpress.stackexchange.com/a/212527/129367 – Michael Sep 16 '18 at 12:02
  • Yes thank you, this is a good idea but I am still wondering if my desired way is possible for ease of use for my end-users. – Summer Developer Sep 17 '18 at 23:23
  • Since you want a combination of both a new submenu item and a custom fields filter, you might be able to create a submenu item with a custom link that reflects the filter, ie. post_type=orders&filter_action=approved. – Michael Sep 18 '18 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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