Archives: Snippets
Publish Future Post
// Publish Future Post / Kiri Vadivelu / 2026 function publish_future_type( $post_data ) { if ( $post_data[‘post_status’] == ‘future’ && $post_data[‘post_type’] == ‘post’ ) { $post_data[‘post_status’] = ‘publish’; } return $post_data; } add_filter(‘wp_insert_post_data’, ‘publish_future_type’); // Remove the automatic future hook…Continue reading
Unrestricted Admin Access
// Unrestricted Admin Access / Kiri Vadivelu / 2026 add_action( ‘admin_init’, ‘restrict_admin_menu’ ); function restrict_admin_menu() { // 1. Define the array of unrestricted users (by email) $unrestricted_users = array( ‘[email protected]’, ‘[email protected]’ ); // 2. Get the current user’s email $current_user…Continue reading
Remove Custom Submenu
// Remove Custom Submenu / Kiri Vadivelu / 2026 add_action( ‘admin_init’, ‘remove_plugin_submenu’ ); function remove_plugin_submenu() { // Parent: options-general.php // Submenu slug: my-plugin-settings // Tools Submenus remove_submenu_page( ‘tools.php’, ‘wp-rollback’ ); // Settings Submenus remove_submenu_page( ‘options-general.php’, ‘log-emails’ ); }Continue reading
Acast Lead Pixel
Acast Web Visits Pixel
Replace Missing Thumbnail
// Replace Missing Thumbnail / Kiri Vadivelu / 2026 function replace_missing_thumbnail( $html, $post_id, $post_thumbnail_id, $size, $attr ) { if ( empty( $html ) ) { // Replace with your site logo URL $logo_url = ‘https://example.com/path/to/logo.png’; $html = ‘‘; } return…Continue reading
Extend Core CSS
/* Extend Core CSS / Kiri Vadivelu / 2026 */ .visually-hidden { border: 0; clip-path: inset(50%); height: 1px; margin: 0; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }Continue reading
Hide Menu Exception
// Hide Menu Exception / Kiri Vadivelu / 2026 add_action( ‘admin_menu’, ‘hide_menu_except’ ); // Visually hide but retain all functions intact function hide_menu_except() { $current_user_id = get_current_user_id(); // Only apply if the user is NOT User ID 1 if (…Continue reading
Search Exclude Page
// Search Exclude Page / Kiri Vadivelu / 2026 add_action(‘pre_get_posts’, ‘exclude_page_search’); function exclude_page_search($query) { if (!is_admin() && $query->is_main_query() && $query->is_search) { $query->set(‘post_type’, ‘post’); } }Continue reading