Remove admin left menu items

function ideapro_remove_wpadmin_menus() { global $current_user; $users = array(3,4,5); $role = $current_user->roles[0]; if($current_user->ID == 1) { } elseif($role == “editor” || $role == “subscriber” || $role == “author”) { remove_menu_page(‘themes.php’); remove_menu_page(‘plugins.php’); remove_menu_page(‘edit.php?post_type=page’); remove_menu_page(‘edit.php?post_type=popup’); remove_menu_page(‘edit.php?post_type=project’); remove_menu_page(‘index.php’); remove_menu_page(‘users.php’); remove_menu_page(‘tools.php’); remove_menu_page(‘upload.php’); remove_menu_page(‘edit.php’); remove_menu_page(‘edit-comments.php’); remove_menu_page(‘options-general.php’);…Continue reading

Display Featured Image in Post List

/* Source: https://rudrastyh.com/wordpress/quick-edit-featured-image.html */ add_filter(‘manage_post_posts_columns’, ‘misha_featured_image_column’); function misha_featured_image_column( $column_array ) { // I want to add my column at the beginning, so I use array_slice() // in other cases $column_array[‘featured_image’] = ‘Featured Image’ will be enough $column_array = array_slice( $column_array,…Continue reading

PvR – ACF Extended Bidirectional update Attention: ONLY ONCE

add_action(‘admin_init’, ‘my_acf_update_bidirectional_posts’); function my_acf_update_bidirectional_posts(){ // bail early if ajax request if(wp_doing_ajax()){ return; } // Retrieve all pages $get_posts = get_posts(array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, )); // Bail early if not found if(empty($get_posts)){ return; } //…Continue reading

Add a Last Modified Column

function wpcode_custom_modified_column_register( $columns ) { $columns[‘last_modified’] = __( ‘Last Modified’, ‘wpcode’ ); return $columns; } add_filter( ‘manage_edit-post_columns’, ‘wpcode_custom_modified_column_register’ ); function wpcode_custom_modified_column_display( $column_name, $post_id ) { if ( ‘last_modified’ != $column_name ) return; echo the_modified_date(); } add_action( ‘manage_posts_custom_column’, ‘wpcode_custom_modified_column_display’, 10, 2…Continue reading

Hide Admin Menu Items

function wpcode_custom_remove_admin_menus(){ // Replace “user_role” with the user role you want to target. if ( ! current_user_can( ‘user_role’) ) { return; } // Hide the comments page. remove_menu_page( ‘edit-comments.php’ ); // Hide WooCommerce page. remove_menu_page( ‘woocommerce’ ); // Hide the…Continue reading

Hide plugins from admin list of plugins

function wpcode_custom_hide_plugins() { // Replace “administrator” with the user role you want to target. if ( ! current_user_can( ‘administrator’ ) ) { return; } // Modify the array to match the plugins you want to hide. $plugins_to_hide = array( ‘plugin-slug/plugin-file.php’,…Continue reading

Duplicate Post/Page Link

// Add duplicate button to post/page list of actions. add_filter( ‘post_row_actions’, ‘wpcode_snippet_duplicate_post_link’, 10, 2 ); add_filter( ‘page_row_actions’, ‘wpcode_snippet_duplicate_post_link’, 10, 2 ); // Let’s make sure the function doesn’t already exist. if ( ! function_exists( ‘wpcode_snippet_duplicate_post_link’ ) ) { /** *…Continue reading

Change “Howdy Admin” in Admin Bar

function wpcode_snippet_replace_howdy( $wp_admin_bar ) { // Edit the line below to set what you want the admin bar to display intead of “Howdy,”. $new_howdy = ‘Welcome ‘; $my_account = $wp_admin_bar->get_node( ‘my-account’ ); $wp_admin_bar->add_node( array( ‘id’ => ‘my-account’, ‘title’ => str_replace(…Continue reading