Is it possible to add an item the Post Publish panel?

You can hook into ‘post_submitbox_misc_actions’ or ‘post_submitbox_start’: add_action( ‘post_submitbox_misc_actions’, ‘wpse_45720_submitdiv_extra’ ); add_action( ‘post_submitbox_start’, ‘wpse_45720_submitdiv_extra’ ); function wpse_45720_submitdiv_extra() { print ‘<pre>’ . current_filter() . ‘</pre>’; }

Sort wp_nav_menu() by menu order

The nav_menu_items are already sorted by menu_order. When you go into the Appearance -> Menus and arrange the order menu the menu_order of each menu item gets updated. To change the orderby parameter in the query that displays the menu you can use pre_get_posts to alter it. Example: add_action( ‘pre_get_posts’, ‘wpse_sort_nav’ ); function wpse_sort_nav( $query … Read more

Show Welcome Panel on Dashboard for every user

This is how I solved it: In functions.php // Custom Dashboard function my_custom_dashboard() { $screen = get_current_screen(); if( $screen->base == ‘dashboard’ ) { include ‘admin/dashboard-panel.php’; } } add_action(‘admin_notices’, ‘my_custom_dashboard’); dashboard-panel.php <!– Hide Old Wrap with CSS –> <style type=”text/css”> div#wpcontent div.wrap { display: none; } div#wpcontent div.my-dashboard { display: block; } </style> <!– New Wrap … Read more

How to make post sticky in the admin page?

“Admin Stickies” for custom post types: To support sticky custom posts in the backend, you can use the following code snippet in your functions.php file in the current theme directory or in your custom plugin: /** * Set admin stickies for the ‘foodmenu’ custom post type */ add_action( ‘init’, function() { if( function_exists( ‘wpse_cpt_stickies’ ) … Read more

Use ‘parse_query’ filter to show posts that from multiple criteria

Ignore my comment about meta_query. Not only does it not work with $query->set(), you wouldn’t be able to control the critical “A OR B” requirement of the query. Instead, I believe what you require is possible via a combination of both the pre_get_posts action hook and posts_where filter hook as follows. add_action(‘pre_get_posts’, ‘my_show_appropriate_posts’); function my_show_appropriate_posts($query){ … Read more

Change Order of Admin Posts Depending on Meta

Post list in admin (edit.php) use a normal WP_Query, just like frontend can be changed using pre_get_posts. add_action(‘pre_get_posts’, ‘reorder_my_cpt’); function reorder_my_cpt( $q ) { if ( !is_admin() || !$q->is_main_query() ) { return; } $s = get_current_screen(); // change ‘book’ with your real CPT name if ( $s->base === ‘edit’ && $s->post_type === ‘book’ ) { … Read more

How to change the title url on the edit post screen?

Use get_edit_post_link filter. add_filter(‘get_edit_post_link’, ‘get_edit_post_link_178416’, 99, 3); function get_edit_post_link_178416($link, $post_id, $context) { $scr = get_current_screen(); if ($scr->id == ‘edit-post’ && $context == ‘display’) { return ‘http://google.com’; } else { return $link; } } You can see it’s used here

Why are my frontend theme styles bleeding into the backend?

You’re supposed to enqueue on the wp_enqueue_scripts event. Placing the function in functions.php and immediately running it, will make it run on all pages, including the admin area Here’s an example from the devhub: /** * Proper way to enqueue scripts and styles. */ function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . … Read more