sortable custom column in media library

You cannot do a sort on the attachment meta data specifically because it’s stored in a serialized string. Whilst WP_Query can sort on meta values it can’t sort on data that’s serialized. For example wp_get_attachment_metadata fetches and unserializes that for you inside the column callback, but MySQL queries can’t sort on that type of data. … Read more

How to search post by ID in wp-admin

Solution 1 Here’s a solution that uses pre_get_posts action to override the original search query and search by post ID instead. This is the approach that I would generally recommend. /** * Allows posts to be searched by ID in the admin area. * * @param WP_Query $query The WP_Query instance (passed by reference). */ … Read more

js error on post editing page

I’d suggest disabling script concatenation and/or compression to see if that helps. You can do this by adding the following to the wp-config.php file: define( ‘CONCATENATE_SCRIPTS’, false ); define( ‘COMPRESS_SCRIPTS’, false ); And maybe even script debugging to.. define( ‘SCRIPT_DEBUG’, true ); Are you using any caching plugins? EDIT: The most common reason for seeing … Read more

Add header and footer to WP backend

The in_admin_header action may be used to insert content before <div id=”wpbody”> in the wordpress backend. See Line 101 of /wp-admin/admin-header.php (line number as of version 3.3.2) Further reading on actions: Action Reference, codex

Remove “Time to upgrade” message from dashboard

How to hide WordPress update mesages CSS The low-tech way to hide something is using css: // Low-tech hiding of update-mesages // source: http://wpsnipp.com/index.php/functions-php/hide-update-nag-within-the-admin/ function remove_upgrade_nag() { echo ‘<style type=”text/css”> .update-nag {display: none} </style>’; } add_action(‘admin_head’, ‘remove_upgrade_nag’); This more-or-less works, but it is a lot of work to find al the places WordPress shows messages. … Read more

How to remove comments option from wp-admin bar and modify profile icon

To remove the comments menu from the top admin bar you can use the $wp_admin_bar global and the remove_menu() method like this: function my_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘comments’); } add_action( ‘wp_before_admin_bar_render’, ‘my_admin_bar_render’ ); As for changing the icon on the settings section of the left admin menu, you can modify the dashicon that is used … Read more

How do I change the login logo URL and hover title?

Try these filters instead // changing the logo link from wordpress.org to your site function mb_login_url() { return home_url(); } add_filter( ‘login_headerurl’, ‘mb_login_url’ ); // changing the alt text on the logo to show your site name function mb_login_title() { return get_option( ‘blogname’ ); } add_filter( ‘login_headertitle’, ‘mb_login_title’ ); Though if you’re on a Network/MultiSite … Read more