How can I bring “Edit Tag” few input and textarea fields in “Quick Edit”

is there any possibility that I’ll able to to bring "Archive Headline" and "Archive Intro Text" into "Quick Edit" (inline-edit) from Edit Tag page.

I am not trying to create new custom input or textarea fields

Read More

I am just talking about if is there any opportunity or way that I can use Edit page options on "Quick Edit". I have read already many tutorials and manage_posts_custom_column quick_edit_custom_box but they are not informing that I can do that.

As I told you that I trying to add fields on Quick Edit Tags so the post type is post_tag.

enter image description here

That’s what I am trying to do.

enter image description here

Related posts

Leave a Reply

1 comment

  1. Yes, you can do this.

    The way WP Tables work – There is a Class ‘WP_List_Table’ (/wp-admin/includes/class-wp-list-table.php) that is used as the basis for all tables (Posts, Categories, Users, Media, etc.), and then the an extender is created for it to make those tables. In class-wp-terms-list-table.php, in the inline_edit() function, there is an action that you need to hook in to.

    Line 356+ reads –

    foreach ( $columns as $column_name => $column_display_name ) {
        if ( isset( $core_columns[$column_name] ) )
            continue;
    
        do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $tax->name );
    }
    

    The benifit of this is that you can create tables that look like the WP standard tables for your custom content, should you wish. This is particularly useful for Plugin developers, or admins of sites where users are not that advanced and feel ‘comfortable’ with only one format of table.

    To add a box to the quick edit, you need to something like the below. The three variables at the top need to be changed to your own settings, which you should have defined when you added the fields to the ‘Edit’ Taxonomy screen –

    /**
     * Adds columns to quick edit
     *
     * @param $column_name string The name of the column that is currently being actioned
     * @param $screen string The screen that is currently being viewed
     * @param $tax string The name of the Taxonomy whose Terms are being listed
     * @return string Current value of the sort_order setting
     */
    function my_custom_box( $column_name, $screen, $name ) {
    
        $my_fields = array(
            array(
                'column_name' => 'archive_headline',
                'field_title' => 'Archive Headline',
                'field_name' => 'archive_headline',
            ),
            array(
                'column_name' => 'archive_intro_text',
                'field_title' => 'Archive Intro Text',
                'field_name' => 'archive_intro_text',
            )
        );
    
        foreach ($my_fields as $field) :
    
            if ( $column_name === $field['column_name'] && $screen === 'edit-tags' ) :
    
                print( '<fieldset><div class="inline-edit-col">' );
                print( '<label>' );
                printf( '<span class="title">%1$s</span>', _e( $field['field_title'] ) );
                printf( '<span class="input-text-wrap"><input type="text" name="%1$s" class="ptitle" value=""></span>', $field['field_name'] );
                print( '</label>' );
                print( '</div></fieldset>' );
    
            endif;
    
        endforeach;
    
    }
    add_action( 'quick_edit_custom_box', 'my_custom_box', 10, 3 );
    

    EDIT

    You have mentioned that you want the values to be in the Quick Edit section of the table, but not the table itself. This is possible, but you have to hide the data. As the Quick Edit section is populated via AJAX using data from the Table, it has to be there.

    You can use the code below to add the columns (you should only have to amend the bit where you actually grab the data, as I don’t know where it comes from).

    /**
     * Add custom data to tables with a low priority, so that post types and taxonomies have already been added
     */
    add_action('init', 'add_custom_columns', 110, 0);
    function add_custom_columns(){
    
        $taxonomy = 'post_tag';
    
        /** Add the column */
        add_filter("manage_edit-{$taxonomy}_columns", 'show_custom_tag_columns', 5);
    
        /** Populate the column */
        add_action("manage_{$taxonomy}_custom_column", 'fill_custom_tag_columns_by_return', 5, 3);
    
    }
    
    /**
     * Shows custom columns and removes built-in ones based on the page being shown
     *
     * @param required array $columns The current columns for the table
     * @return array $columns The updated columns array
     */
    function show_custom_tag_columns($columns){
    
        if($pagenow === 'edit-tags.php' && !isset($_GET['post_type'])) :
    
            $columns['archive_headline'] = __('Archive Headline');
            $columns['archive_intro_text'] = __('Archive Intro Text');
    
        endif;
    
    }
    
    /**
     * Adds the IDs to the ID column where data must be returned
     *
     * @param required array $value Not sure what this is...
     * @param required array $column_name The name of the current column
     * @param required array $object_id The object ID
     * @return array $defaults Updated list of table columns
     */
    function fill_custom_tag_columns_by_return($column_values, $column_name, $object_id){
    
        global $wpdb;
    
        echo $column_values; // Output any pre-existing column values so they don't get over written
    
        if($column_name === 'archive_headline') :
            // Do what ever you do to get the data for this column
            return $archive_headline;
        endif;
        if($column_name === 'archive_intro_text') :
            // Do what ever you do to get the data for this column
            return $archive_intro_text;
        endif;
    
    }
    

    And to hide the columns, add the following CSS –

    table.widefat th.column-archive_headline,
    table.widefat th.column-archive_intro_text{
        display: none;
    }