Articles of admin

Creating a new page and automatically associating it with a template in WordPress

I’ve got three page templates called “Simple”, “Front”, and “Form” and I would like to add a shortcut in the admin side bar to directly create a page that would be associated with any of these templates. So below “Add new” there would be: Add new Simple Page Add new Front Page Add new Form […]

how to only add a top-level admin menu without it creating a sub-level-menu

Here is a the code snippet: add_action( ‘admin_menu’, ‘travel_site’ ); function travel_site(){ add_menu_page( ‘Travel Site Menu’, ‘Travel Site’, ‘manage_options’, ‘travel-site-menu’, ‘ts_admin_main_page’ ); add_submenu_page(“travel-site-menu”,”View Travel Requests”,”View Travel Requests”,”manage_options”,”ts-view-travel-requests”,”ts_admin_vtr_page”); } function ts_admin_main_page(){ echo ‘<div class=”wrap”>’; echo ‘<p>Testing main travel site menu page</p>’; echo ‘</div>’; } function ts_admin_vtr_page(){ echo ‘<div class=”wrap”>’; echo ‘<p>Testing view travel requests</p>’; echo ‘</div>’; […]

Remove admin AND editor from the “change role to” menu in user listing

I have a snippet in my functions.php that removes the admin role from the “change role to” drop down menu in the users listing screen, so that editors who can list users and manage roles won’t be able to turn another user into an admin. The code below works perfectly. function isa_pre_user_query($user_search) { $user = […]

Different Admin Theme – Based on Role?

I’m wondering how to change the admin theme based on a user’s role. Currently I can change the admin theme using a plugin (ex: Blue Admin) – but I’m not sure how to make those changes based on a role (subscriber etc). Would also like to have specific menu items / etc shown only for […]

How to make certain page templates visible to admin only

Making a site for a client, I have some pages that the client won’t be able to edit or delete. These pages rely on specific page templates. However, I don’t want these templates to be available for the client when creating new pages. Is there someway to hide these certain page template from the page […]

How to remove categories filter from wordpress admin?

I removed the categories column from “All posts” page by applying this code. add_filter(“manage_edit-post_columns”, “my_post_edit_columns”); function my_post_edit_columns($columns){ unset($columns[‘categories’]); return $columns; } This code removed categories column. But still i see the categories filter in the top. Is there a way to remove it other than using CSS to hide it? Thanks

How to show custom (checkbox) field value in admin post list?

I have a custom post type for products and a custom meta checkbox field for ‘Sold’. How can I show the Sold status in a column on the Products edit list and make it sortable (so it would sort all the sold items together) or filter them by the Sold status?

Only allow new subpages to be created

I’m looking for a way to only allow users to create new subpages once there are nine pages that are parents/root pages. Once there are nine parent pages when trying to create a new parent the users will get an error message. Edit: Moved from the comments to @brasofilo s answer below: when I press […]

How can I activate Collapse Menu in WordPress?

Inside the WordPress admin dashboard there is a button for making the left side menu collapse (to show just icons and not the icons + text on left side). How can I add jQuery so that it gets automatically collapsed once my plugin opens up. I tried this but it didn’t work for me. I […]

Add a Custom Class to Admin Menus

I am looking for a way to add some custom classes to the admin menus using PHP. For example, here are the li tag for Posts and Pages: <li id=”menu-posts” class=”wp-has-submenu wp-has-current-submenu wp-menu-open open-if-no-js menu-top menu-icon-post menu-top-first”> <li id=”menu-pages” class=”wp-has-submenu wp-not-current-submenu menu-top menu-icon-page”> In the Posts li tag I would like to add a custom […]