Disable Posts in Admin
add_action( ‘admin_bar_menu’, function ( $wp_admin_bar ) { $wp_admin_bar->remove_node( ‘new-post’ ); }, 100 ); add_action( ‘admin_menu’, function () { remove_menu_page( ‘edit.php’ ); } );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_action( ‘admin_bar_menu’, function ( $wp_admin_bar ) { $wp_admin_bar->remove_node( ‘new-post’ ); }, 100 ); add_action( ‘admin_menu’, function () { remove_menu_page( ‘edit.php’ ); } );Continue reading
add_filter( ‘get_avatar’, function( $avatar, $id_or_email, $size, $default, $alt ) { return ”; // Return an empty string to disable the gravatar }, 10, 5 );Continue reading
// Return a 404 page for author pages if accessed directly. add_action( ‘template_redirect’, function () { if ( is_author() ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } ); // Remove the author links. add_filter( ‘author_link’, ‘__return_empty_string’, 1000…Continue reading
add_filter( ‘wp_revisions_to_keep’, function( $limit ) { // Limit to the last 20 revisions. Change 20 to whatever limit you want. return 20; } );Continue reading
add_action( ‘init’, function() { if ( ! current_user_can( ‘manage_options’ ) && ! is_admin() && ! is_login() ) { wp_die( ‘This website is currently undergoing scheduled maintenance. Please try again later.’ ); } } );Continue reading
add_action( ‘wp_default_scripts’, function ( $scripts ) { if ( ! is_admin() && isset( $scripts->registered[‘jquery’] ) ) { $script = $scripts->registered[‘jquery’]; if ( ! empty( $script->deps ) ) { $script->deps = array_diff( $script->deps, array( ‘jquery-migrate’ ) ); } } }, 150…Continue reading
add_filter( ‘wp_handle_upload’, function ( $file ) { $max_width = 1920; $max_height = 1920; // Check if the file is an image. $mime_type = mime_content_type( $file[‘file’] ); if ( strpos( $mime_type, ‘image’ ) === false ) { return $file; } //…Continue reading
/* Shortcode for Gate and Service Road Checklist */ function check_status( $formValue ) { $gateClass = ‘gate-opened’; if ($formValue == ‘Closed’) { $gateClass = ‘gate-closed’; } return “” . $formValue . ““; } function build_gate_service_road_checklist() { $output = ”; $search_criteria…Continue reading
add_filter( ‘get_the_archive_title’, function ( $title ) { if ( is_tag() ) { $title = single_tag_title( ”, false ); // ← just the tag name } return $title; } );Continue reading
function register_custom_meta_fields() { $fields = [ // Fields that should be of type ‘string’ ‘zip_code’ => ‘string’, ‘city’ => ‘string’, ‘state’ => ‘string’, ‘state_full’ => ‘string’, ‘county’ => ‘string’, ‘best_network’ => ‘string’, // Fields that should be of type ‘number’…Continue reading