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 hide or remove unwanted widgets on Multisite installation?

Add this to your functions.php file: function jpb_unregister_widgets(){ unregister_widget(‘WP_Widget_Pages’); unregister_widget(‘WP_Widget_Calendar’); unregister_widget(‘WP_Widget_Archives’); unregister_widget(‘WP_Widget_Links’); unregister_widget(‘WP_Widget_Meta’); unregister_widget(‘WP_Widget_Search’); unregister_widget(‘WP_Widget_Text’); unregister_widget(‘WP_Widget_Categories’); unregister_widget(‘WP_Widget_Recent_Posts’); unregister_widget(‘WP_Widget_Recent_Comments’); unregister_widget(‘WP_Widget_RSS’); unregister_widget(‘WP_Widget_Tag_Cloud’); unregister_widget(‘WP_Nav_Menu_Widget’); } add_action( ‘widgets_init’, ‘jpb_unregister_widgets’ ); This will get rid of all default widgets. If you want to keep a certain widget, remove that line from the function above.

Admin menu as submenu from another plugin

Trying to simulate the issue, it happened the same (wp-admin/submenu_slug), and the solution is to add a priority value in the hook admin_menu. Here, I’m adding a sub menu to the plugin BackWPup. Note the priority 11: add_action(‘admin_menu’, ‘third_party_submenu_wpse_91377’, 11 ); function third_party_submenu_wpse_91377() { add_submenu_page( ‘backwpup’, // Third party plugin Slug ‘My plugin’, ‘My plugin’, … Read more

How to influence the information displayed on widget inside wp-admin

Background: The reason why filtering with dynamic_sidebar_params doesn’t work with HTML is because WordPress strips HTML from Widget Heading in wp_widget_control() function like this: $widget_title = esc_html( strip_tags( $sidebar_args[‘widget_name’] ) ); WordPress also strips HTML in default JavaScript in wp-admin/js/widgets.js So without a customised solution, there is no default filter or option either with PHP … 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