最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - Remove specific items from Quick Edit menu of a Custom Post Type?

programmeradmin9浏览0评论

I would like to remove some items from the quick edit screen on a custom post type.

I would like to remove "slug", "date" and "password", as they will never not be used by end users.

I'm open to any suggestions!

I would like to remove some items from the quick edit screen on a custom post type.

I would like to remove "slug", "date" and "password", as they will never not be used by end users.

I'm open to any suggestions!

Share Improve this question edited Jul 28, 2012 at 6:46 brasofilo 22.1k8 gold badges70 silver badges264 bronze badges asked Jul 27, 2012 at 11:00 gArngArn 2202 silver badges5 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 8

There's no hooks to modify the Quick Edit, it has to be done with CSS and/or jQuery.

The plugin Adminimize is very good to hide administrative elements, CPTs included.

But in the Quick Edit box, for lack of CSS classes or ID's to target, it is not possible to hide the slug field, and only possible to partially hide the date adding a custom option as in the following snapshot.


click to enlarge


So, a pure jQuery solution is necessary:

add_action( 'admin_head-edit.php', 'wpse_59871_script_enqueuer' );

function wpse_59871_script_enqueuer() 
{    
    /**
       /wp-admin/edit.php?post_type=post
       /wp-admin/edit.php?post_type=page
       /wp-admin/edit.php?post_type=cpt  == gallery in this example
     */

    global $current_screen;
    if( 'edit-gallery' != $current_screen->id )
        return;
    ?>
    <script type="text/javascript">         
        jQuery(document).ready( function($) {
            $('span:contains("Slug")').each(function (i) {
                $(this).parent().remove();
            });
            $('span:contains("Password")').each(function (i) {
                $(this).parent().parent().remove();
            });
            $('span:contains("Date")').each(function (i) {
                $(this).parent().remove();
            });
            $('.inline-edit-date').each(function (i) {
                $(this).remove();
            });
        });    
    </script>
    <?php
}

Related quick-edit Q&A's that I've worked

  • How to Remove the "Restore" Link in Quick Edit?
  • How do I limit the status options for bulk/quick edit to only Published and Draft?
  • Remove Posts Quick Edit link for specific user role? WP 3.3
  • Inserting a Download Link in the Quick Edit Actions of the Media Library?
  • How to remove a parent theme template from Quick Edit?
  • Show draft pages in page attributes parent page dropdown

Remove category select with filter:

add_filter( 'quick_edit_show_taxonomy', function( $show, $taxonomy_name, $view ) {

    if ( 'category' == $taxonomy_name )
        return false;

    return $show;
}, 10, 3 );

This solution doesn't work if you use Wordpress in another language than English:

$('span:contains("Password")').each(function (i) {
    $(this).parent().parent().remove();
});

If you want to use it independently of language you should use something like this:

$( "input[class*='password']" ).each(function (i) {
    $(this).closest('div').remove();
})

It removes the parent DIV of INPUT with class that contains word "password".

发布评论

评论列表(0)

  1. 暂无评论