Hide a theme on list of themes in wp-admin without editing core files

The following filter works in Multisite in the following screens: /wp-admin/network/themes.php /wp-admin/network/site-themes.php?id=1 (individual sites allowed themes) add_filter( ‘all_themes’, ‘wpse_55081_remove_themes_ms’ ); function wpse_55081_remove_themes_ms($themes) { unset($themes[‘Twenty Ten’], $themes[‘Twenty Eleven’]); return $themes; } For the regular theme selector in a single site or sub-site of a network /wp-admin/themes.php (Appearance -> Themes), looks like there’s no hook… Manipulate list … Read more

Is it possible to show custom comment metadata in the admin panel?

To show the content on individual edit pages you need to add custom meta boxes to the comment edit page. You’ll use the key comment for the $page argument of add_meta_box. <?php add_action( ‘add_meta_boxes_comment’, ‘pmg_comment_tut_add_meta_box’ ); function pmg_comment_tut_add_meta_box() { add_meta_box( ‘pmg-comment-title’, __( ‘Comment Title’ ), ‘pmg_comment_tut_meta_box_cb’, ‘comment’, ‘normal’, ‘high’ ); } function pmg_comment_tut_meta_box_cb( $comment ) … Read more

How to add a style to taxonomy edit page

You can do it like this: add_action (‘admin_enqueue_scripts’, ‘wpse_style_tax’) ; function wpse_style_tax () { // these 3 globals are set during execution of {edit-tags,term}.php global $pagenow, $typenow, $taxnow ; if (!in_array ($pagenow, array (‘edit-tags.php’, ‘term.php’)) { return ; } if (‘news’ != $typenow) { return ; } if (‘news-category’ != $taxnow) { return ; } … Read more

Add a button to users.php

Okay.. you COULD add a button like you mentioned; but I think this is going to require a lot more code. The users.php page is using the WP List Table class.. which means we can hook into the bulk actions and add our custom value there. So, let’s create a function to add a new … Read more

“leftover” notifications left on ever admin screen?

Let’s take a look at admin_notices, since that’s where your output is. https://core.trac.wordpress.org/browser/tags/5.4/src/wp-admin/admin-header.php#L281 So, it’s simply just an action-as-an-output-spot, what this means is that if you wish, you can output anything here and most importantly, this all happens in-memory, so, debugging should be pretty straight-forward; this spot is meant to output things. That’s it. Unless … Read more

Easiest way to make post private by default

Accepted solution is not the correct answer to change the visibility of any post type to any status. Below code is the right way to change the post status. function set_post_type_status_private( $status, $post_id ) { $status=”private”; return $status; } add_filter( ‘status_edit_pre’, ‘set_post_type_status_private’, 10, 2 ); Updated: The above filter will change the post status to … Read more

Reorder custom submenu item

Got it, thanks to cjbj‘s help, I was able to get the final solution: add_filter( ‘custom_menu_order’, ‘submenu_order’ ); function submenu_order( $menu_order ) { # Get submenu key location based on slug global $submenu; $settings = $submenu[‘options-general.php’]; foreach ( $settings as $key => $details ) { if ( $details[2] == ‘blogging’ ) { $index = $key; … Read more

How to Display Post Excerpts in Admin by Default?

The names of unchecked boxes in Screen Options for Edit Post screen are stored in user’s meta, per individual user, as an array. Insert the following code in your theme’s functions.php: function wpse_edit_post_show_excerpt( $user_login, $user ) { $unchecked = get_user_meta( $user->ID, ‘metaboxhidden_post’, true ); $key = array_search( ‘postexcerpt’, $unchecked ); if ( FALSE !== $key … Read more

Using the loop inside admin

I am not sure about the issue, but my advice would be to try and refactor this to use get_posts() and template tags that can work without $post global variable. Basically do not touch globals at all. Loops in front-end are almost civilized nowadays, but internals of admin are still very wild. 🙂