Adding a text link under the post title in the lists of posts

You can enhance, change the strings to each post title in the table view of backend on post via hook: add_filter( ‘post_row_actions’, array( $this, ‘add_archive_link’ ), 10, 2 ); See the result in this screenshot: Below you find my method to add a link /** * Add link on archive * * @uses get_post_type_object, get_archive_post_link, … Read more

Custom Admin Menu Order

The actual slug for the WooCommerce menu item is ‘woocommerce’. So if you replace: ‘edit.php?post_type=shop_order’, // WooCommerce with: ‘woocommerce’, // WooCommerce the above code will work. I found a handy function that will display all the items in the menu array at How to remove admin menu pages inserted by plugins?. Here is the function … Read more

How to restrict wp-admin and prevent upload errors

You just need one extra thing for this. Here is the code I typically use to do what you are doing: function pws_block_admin() { if ( // Look for the presence of /wp-admin/ in the url stripos($_SERVER[‘REQUEST_URI’],’/wp-admin/’) !== false && // Allow calls to async-upload.php stripos($_SERVER[‘REQUEST_URI’],’async-upload.php’) === false && // Allow calls to admin-ajax.php stripos($_SERVER[‘REQUEST_URI’],’admin-ajax.php’) … Read more

Set a default category – if the user didn’t select one- before creating a post

Maybe this is what you are looking for? Source is from @Michael Fields /** * Set default cat for cpt * @source {https://circlecube.com/says/2013/01/set-default-terms-for-your-custom-taxonomy-default/} * @source {http://wordpress.mfields.org/2010/set-default-terms-for-your-custom-taxonomies-in-wordpress-3-0/} * @license GPLv2 */ function set_default_object_terms_203962( $post_id, $post ) { if ( ‘publish’ === $post->post_status ) { $defaults = array( //’your_taxonomy_id’ => array( ‘your_term_slug’, ‘your_term_slug’ ) ‘post_tag’ => array( … Read more

How to remove “publish metabox” from each post type

If you’re familiar with Browser Developer Tools you can quickly find the metabox ID ( which is the container div id ). In this case it’s called submitdiv. We can remove it by using the remove_meta_box() function which has a format like this: remove_meta_box( ‘metabox_id’, ‘post_type’, ‘default_position’ ); remove_meta_box( ‘submitdiv’, ‘post’, ‘side’ ); Here’s a … Read more

How do I add a custom body class to the admin area of a page?

Use admin_body_class both with global post_id and get_current_screen function: add_filter(‘admin_body_class’, ‘wpse_320244_admin_body_class’); function wpse_320244_admin_body_class($classes) { global $post; // get_current_screen() returns object with current admin screen // @link https://codex.wordpress.org/Function_Reference/get_current_screen $current_screen = get_current_screen(); if($current_screen->base === “post” && absint($post->ID) === 8) { $classes .= ‘ home-admin-area’; } return $classes; } You can also use $pagenow variable. It seems that … Read more