407 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Elite Author
  • Author Level 9
+7 more
EugeneO
says

I’m trying to create a custom post type that does not have the “Add New” option. The idea is that the pages for this post type will be automatically generated. I have the custom post type working fine but how do I edit the capabilities to prevent the “Add New” option from appearing?

2627 posts Put a Donk On It
  • Weekly Top Seller
  • Elite Author
  • Exclusive Author
  • Featured Author
+11 more
ThemeProvince
says

I think you possbly could use the capability_type parameter when you register a custom post type but im not too sure.

1149 posts
  • Affiliate Level 1
  • Author Level 3
  • Beta Tester
  • Collector Level 2
+3 more
fillerspace
says

There is a show_ui and show_in_menu parameter when you register a custom post type. Not sure if you want to completely hide these, or make them editable once automatically generated.

407 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Elite Author
  • Author Level 9
+7 more
EugeneO
says

I have been reading about the capabilites and capatility_type parameters but I can’t get my head around them.

@fillerspace: I want users to be able to see and even edit the content from the admin dashboard once it has been generated but I do not want them to be able to create this type of content from scratch simply because there will be no need for them to. So I’m just looking for a way to remove the “Add New” buttons.

140 posts
  • 4 Years of Membership
  • Affiliate Level 2
  • Author Level 3
  • Collector Level 2
+1 more
weblusive
says
Hi Eugene, here is a solution I came over:

function hide_add_new_custom_type()
{
    global $submenu;
    // replace my_type with the name of your post type
    unset($submenu['edit.php?post_type=my_type'][10]);
}
add_action('admin_menu', 'hide_add_new_custom_type');

Not the most elegant solution, but it actually works. Please let me know if this helped.
407 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Elite Author
  • Author Level 9
+7 more
EugeneO
says

Thanks for the try, weblusive. It’s almost a fix as it removes the “Add New” link in the sidebar but using your method the “Add New” button on the page that lists all the posts is still there.

2468 posts
  • 6 Years of Membership
  • Author Level 2
  • Affiliate Level 4
  • Beta Tester
+3 more
digitalimpact
says

Hiding them with CSS would be another not-so-elegant solution… However, you’d still be able to access the “add new” directly…

by
by
by
by
by
by