You are viewing an old revision of this post, from March 15, 2015 @ 13:33:02. See below for differences between this version and the current revision.

Stop users from adding new pages or posts

[php]// Hide the "add new" submenu for a custom post type // uses the custom function get_current_post_type() add_action('admin_menu', 'pp_hide_YOUR_CPT_addnew_submenu'); function pp_hide_YOUR_CPT_addnew_submenu() { global $submenu; unset($submenu['edit.php?post_type=YOUR_CPT'][10]); } // Hide the "add new" button on a custom post type edit page add_action('admin_head','pp_hide_YOUR_CPT_addnew_button'); function pp_hide_YOUR_CPT_addnew_button() { global $pagenow; if(is_admin()){ if( ($pagenow == 'edit.php' && get_current_post_type() == 'YOUR_CPT') || ($pagenow == 'post.php' && get_current_post_type() == 'YOUR_CPT') ){ echo '<style>'; echo '.add-new-h2{'; echo 'display: none;'; echo '}'; echo '</style>'; } } }[/php]

Revisions

  • March 15, 2015 @ 13:33:02 [Current Revision] by PeterLugg
  • March 15, 2015 @ 13:33:02 by PeterLugg

Revision Differences

There are no differences between the March 15, 2015 @ 13:33:02 revision and the current revision. (Maybe only post meta information was changed.)

Tags: ,

No comments yet.

Leave a Reply