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

How do I add custom columns to my 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 need to manually configure them.

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.

Also, 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.

"post_excerpt" => "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 04, 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 04, 2014 07:20