Secure Admin Menu

// Secure Admin Menu / Kiri Vadivelu / 2026 add_action( ‘admin_init’, ‘secure_admin_menu’ ); function secure_admin_menu() { // Replace 1 with the actual User ID of the owner $owner_id = 1; global $user_ID; // 1. If not owner, remove from sidebar…Continue reading

Custom Admin Menu

// Custom Admin Menu / Kiri Vadivelu / 2026 add_action( ‘admin_init’, ‘owner_admin_menu’ ); function owner_admin_menu() { // Replace 1 with the actual User ID of the owner $owner_id = 1; global $user_ID; // If the current user is NOT the…Continue reading

Max Upload Size

// Max Upload Size / Kiri Vadivelu / 2026 function max_upload_size( $file ) { $max = 9 * 1024 * 1024; // 9 MB if ( $file[‘size’] > $max ) { $file[‘error’] = ‘File exceeds the 9 MB maximum upload…Continue reading

Image Max Pixel

// Image Max Pixel / Kiri Vadivelu / 2026 add_filter(‘wp_handle_upload_prefilter’, ‘image_max_pixel’); function image_max_pixel($file) { $image = getimagesize($file[‘tmp_name’]); if ($image[0] > 4000 || $image[1] > 4000) { $file[‘error’] = ‘Image too large (max 4000×4000).’; } return $file; }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 = ‘Heya,’; $my_account = $wp_admin_bar->get_node( ‘my-account’ ); if ( ! isset( $my_account->title ) ) { return;…Continue reading

Add Last Modified Column

add_filter( ‘manage_posts_columns’, function ( $columns ) { $columns[‘last_modified’] = __( ‘Last Modified’ ); return $columns; } ); add_action( ‘manage_posts_custom_column’, function ( $column, $post_id ) { if ( ‘last_modified’ === $column ) { $modified_time = get_the_modified_time( ‘Y/m/d g:i:s a’, $post_id );…Continue reading

Add ID column in admin tables

add_action( ‘admin_init’, function () { // Get all public post types $post_types = get_post_types( array(), ‘names’ ); function wpcode_add_post_id_column( $columns ) { $columns[‘wpcode_post_id’] = ‘ID’; // ‘ID’ is the column title return $columns; } function wpcode_show_post_id_column_data( $column, $post_id ) {…Continue reading

List All URLs

// List All URLs / Kiri Vadivelu / 2026 add_action(‘admin_menu’, ‘add_url_list_page’); function add_url_list_page() { add_management_page(‘All URLs’, ‘All URLs’, ‘manage_options’, ‘all-urls’, ‘display_all_urls’); } function display_all_urls() { $args = array( ‘post_type’ => array(‘post’, ‘page’), ‘post_status’ => ‘publish’, ‘numberposts’ => -1 ); $posts…Continue reading