Doc WordPress WordPress Tricks, Tips & Snippets


Prevent change of positions of admin meta boxes

For some clients I prefer to really lock down the WordPress admin. They get confused if they accidently move one of the many meta boxes in the backend and then they'll call and tell me that the system wouldn't work anymore. So I was gald to find this little snippet which will prevent that any change of the meta boxes will be saved:

/* Prevent Save of backend Meta Box positions */
 add_action('check_ajax_referer', 'prevent_meta_box_order');
function prevent_meta_box_order($action) {
	if ('meta-box-order' == $action ) {

Just put this in your functions.php and you're set!


Load a custom CSS file in WordPress admin

With this little snippet you can load your own css file into the WordPress admin which will allow you to easily hide unneeded items to keep the admin clean and tidy and avoid unnecessary confusion for our clients:

// The function include a css files for backend
function backend_css_style() {
	echo '<link rel="stylesheet" href="' . get_stylesheet_directory_uri() . '/admin.css" type="text/css" media="all" />';
add_action('admin_head', 'backend_css_style');

Just this into your functions.php and also put a "admin.css" file into your child theme folder 🙂


Remove unnecessary stuff from WordPress header

By default WordPress adds quite some meta junk to your site's <head>. Luckily for us these can easily be disabled without the need to install a plugin for this (remember: the less plugins the better). Just add this to your website's functions.php (found in your theme folder):

remove_action('wp_head', 'wp_generator'); // remove wp version header
remove_action('wp_head', 'wlwmanifest_link'); // remove MS-live writer
remove_action('wp_head', 'rsd_link'); // remove Really Simple Discovery
remove_action( 'wp_head', 'feed_links_extra', 3 ); // remove Comments Feed