Knowledge Base/Custom Bulk/Quick Edit/Frequently Asked Questions

How do I add custom fields to my bulk/quick edit page?

Michael Cannon
posted this on July 13, 2013, 13:17

If the fields you want aren't already showing up automatically at WP Admin > Settings > Custom Bulk/Quick Edit, then you'll need to manually configure them.

In a best case scenario, the name of the post meta field and those shown in the columns are same. Therefore, the quick and easy code below is for you. If not, you'll need to check out the Working Examples below for dealing with different incoming, shown, and saved field names. 

You'll need to know the custom key name of the field you're wanting to change and the values associated with them. You'll probably need to dig through your plugin or theme code for these. Then in your theme's `functions.php` file add code similar to the following.

add_filter( 'manage_post_posts_columns', 'my_manage_post_posts_columns' );
function my_manage_post_posts_columns( $columns ) {
	$columns['custom_stuff'] = esc_html__( 'Custom Stuff Here' );

	return $columns;
}

As an example of working with a custom post type named `news-room`, try the following.

add_filter( 'manage_news-room_posts_columns', 'my_manage_newsroom_posts_columns' );
function my_manage_newsroom_posts_columns( $columns ) {
	$columns['wpcf-publication-author'] = esc_html__( 'Publication Author');
	$columns['wpcf-newsroom-type']      = esc_html__( 'News Room Type');
	$columns['_views_template']         = esc_html__( 'Content Template');

	return $columns;
}

This is based upon the filter manage_${post_type}_posts_columns for the `post` post type.

Once you've got these, you can check Value configurations to finish up your Settings > CBQE options.

Working Examples

Check out the article Where can I find working samples? for more help.

What About Excerpts?

If your theme supports excerpts, then try the following in your filter.

$columns['post_excerpt'] = esc_html__( 'Excerpt');

Don't Forget!

Once you add your fields, go back to WP Admin > Settings > Custom Bulk/Quick to enable the field.

Thank you to widecast for this reminder.

 

Comments

User photo
Onlinepurchase

I was able to get this working but I have two problem.

1.) My quick edit field is showing me an ID number instead of the Template Name that is associated with the id.

2.) It is showing the information in a text field instead of a selection popup.

How can I correct these two problems?

 

When I inspect the field in my post page I see this information:

 

<div class="dslca-post-options">

    <div class="dslca-post-option">
        <div class="dslca-post-option-label"></div>
        <!--

         .dslca-post-option-label

        -->
        <div class="dslca-post-option-field dslca-post-option-field-select">
            <select id="dslc_post_template" name="dslc_post_template" type="text"></select>
        </div>
        <!--

         .dslca-post-option-field

        -->
    </div>
    <!--

     .dslca-post-options

    -->
    <input type="hidden" value="dslc-post-tpl-options" name="dslc_post_options[]"></input>

</div>
<!--

 .dslca-post-options

-->

February 20, 2014, 01:02
User photo
Onlinepurchase

This is what I inserted into my functions.php file:

 

add_filter( 'manage_post_posts_columns', 'my_manage_post_posts_columns' );
function my_manage_post_posts_columns( $columns ) {
    $columns['dslc_post_template'] = esc_html__( 'LC Template' );

    return $columns;
}

February 20, 2014, 01:04
User photo
Michael Cannon
Aihrus

I suggest checking out the linked to code at https://aihrus.zendesk.com/entries/27667723. You're going to need to use more filters.

February 20, 2014, 03:06
User photo
Andrew Biggs

Hi Michael, I am trying to apply this to a custom post type called 'branch' I manually added the columns but they show for standard posts only.

How can I make the columns show in only the custom post type called 'branch' and NOT the standard post types?

 

Thanks

 

Andy

April 4, 2014, 04:27
User photo
Michael Cannon
Aihrus

Andy, check out the code below "As an example of working with a custom post type named `news-room`, try the following". You need to replace `_post_` with your `_branch_` post type probably.

April 4, 2014, 07:20
User photo
Tarantino

I am using Types plugin for custom fields and custom post types. I have set a CF for my CPT and everything is working. I installed the plugin and I noticed the CF didn´t show. So I found this thread and added the code above which does then give me a column, but data isn´t saving to the CF if I go and check inside the post. What am I missing?

June 28, 2014, 06:01
User photo
Michael Cannon
Aihrus

@Tarantino, the problem is probably due to the field name coming in, isn't the same in the post meta field. I've run into soo often and that is why automatic detection and saving can be a pain. I suggest checking out the working examples links above to view more code dealing with `save_edit` and columns of differing field names.

June 30, 2014, 00:28
User photo
Sueli Vieira

Everything works well, except that the Custom Field to be edited (item#) shows blank and not with the current content (so I can see if it needs to be edited).

Other fields, like Title, Slug, Date, Status, etc. all show populated with the data previously entered. Only CF item# shows blank.

CF item# Field Type is TEXT. At CBQE Settings I don't see the option to enable as TEXT so I chose TEXTAREA. Can this be the issue?

 

 

Code I used:

 

add_filter( 'manage_products_posts_columns', 'my_manage_products_posts_columns' );
function my_manage_products_posts_columns( $columns ) {
$columns['item#'] = esc_html__( 'Item #' );

return $columns;
}

Thanks

 

 

 

January 26, 2015, 10:21
User photo
Sueli Vieira

Another Problem.

I added 2 more fields to edit. The 3 fields are: item#, perbox, and size.

add_filter( 'manage_products_posts_columns', 'my_manage_products_posts_columns' );
function my_manage_products_posts_columns( $columns ) {
$columns['item#'] = esc_html__( 'Item #' );
$columns['perbox'] = esc_html__( 'Per Box' );
$columns['size'] = esc_html__( 'Size' );

return $columns;
}

 

Quick Edit does not populate the existing data on these Custom Fields. The fields appear empty.

When I click UPDATE, it erases the data.

So if I quick edit the item#, when I click UPDATE, the fields perbox and size are erased.

 

 

 

 

January 26, 2015, 11:08
User photo
Michael Cannon
Aihrus

Sueli, I'm sorry about the troubles. Have you confirmed that those field name indexes are indeed the data field names in your post types meta data? Check out `wp_postmeta` to confirm.

January 26, 2015, 23:11
User photo
Sueli Vieira

Yes, they are. I have opened a ticket for that.

Thanks!

January 27, 2015, 06:26