Skip navigation

79 Replies to “Manage WordPress Posts Using Bulk Edit and Quick Edit”

  1. Jacob Tekiela says:

    Great writing Rachel!! thanks for the effort!
    what if you wanted to do a quick edit with the “normal” postdate – how would that be feasible?

      1. Jacob Tekiela says:

        I need to backdate hundreds of posts. And for some strange reason WP has chosen NOT to allow bulk-editing of the date. (you can change the Author and Status et al.)
        It’s only possible when you do single post Quick Edit. If only one could add the standard date to the bulk edit too – that would be SO great……Other people must have that very basic need.
        I have REALLY been searching hi and low and your excellent idea is the closest I have come so far……… thank you again !!

        1. Rachel Cherry says:

          Ah. I was confused because in quick edit you CAN edit the date. But you’re right, in bulk edit you can’t edit the date. You could use this tutorial to add the date to bulk edit, though =)

          1. Hi, I added your code and uploaded the .js but there is noting, no column, what’s wrong ?
            I tried with my custom post and custom field replacing “movies” by “property” and “realease_date” by “price” but same problem…
            Do you know how to fix it ?
            Thanks 🙂

  2. jwdavis1957 says:

    Rachel, this looks like the tool I need to update publication dates en masse.  I want to implement the code changes, but I do not know where to paste the code.  I downloaded your .zip files and have them open on my desktop.  Where do I paste them, Rachel?  Or do you have a plugin now?

    1. Rachel Cherry says:

      Paste the code from my functions.php file into your theme’s functions.php file and then just place the quick_edit.js file in the same folder as your functions.php file.

      1. jwdavis1957 says:

        Thanks.  I tried this using two different themes, and placed your code after the themes functions.php code.  I used only one , and I removed the /* and */ as you //commented in the first line.  Cannot get it to work.  Removing all original functions.php code did not work, and placing your code above the original functions.php did not work.  I am a wee bit bamfoozled by this.  Any suggestions, Rachel?  I am really dying to see it work now.  You know how it is… we get a little obsessive about things sometimes 🙂

        1. Instead of copying and pasting the code into your theme’s `functions.php` file, you could attempt to include it at the bottom via `include_once ‘rachels_functions.php`;`. Just make sure to save `rachels_functions.php ` file in the same directory as your theme that your editing `functions.php`.

  3. Hey,
    Nice tut, but I have a problem. The js don’t populate my field with the existing value of custom meta in quick edit menu. Is still work?

    1. Rachel Cherry says:

      You probably have a typo in your code somewhere. Check that the id tag for the element in your field’s custom column (step 2) matches the code in the jquery (step 4) that retrieves the info from the column.
      In my example, my custom column looks like:
      echo ” . get_post_meta( $post_id, ‘release_date’, true ) . ”;
      And the jquery looks like:
      var $release_date = $( ‘#release_date-‘ + $post_id ).text();
      See how the “release_date-{post id}” needs to match? If that’s not the problem, make sure the existing value is being printed in the custom column and that it’s wrapped in your with the matching ID.

      1. Yeaaah! Thanks a lot, it works.!!
        Btw, I see you know very well WordPress. I have other question, but off topic.
        Can I ask you?
        Ok, I will try 🙂
        I want to list posts (build in posts) sorted by by percentage discount value between two meta key values.
        meta_key = price
        meta_key = lowprice
        discount = (price – lowprice) / price * 100)
        I want to order posts by this result. Can you help me with that?
        Original question is here

          1. I still don’t have any help on my special order problem, maybe if you have time, you can give me some help.

  4. Hey again,
    Is there any way to change the active field in quick edit? I want to set my custom field from quick edit to be active, not the title as it by default.

    1. Rachel Cherry says:

      Hey. Sorry for the delay. Didn’t even know I had a comment!
      Yea. That’s easy! If we were looking at the code in the ‘Populate Your “Quick Edit” Data’ section, we would add the following line after we populated the release date:
      $edit_row.find( ‘input[name=”release_date”]’ ).focus();

  5. Rachel, i just love you ^_^ the wordpress documentation is a constant disappointment, but your tuto brought me some light!! thank you

  6. I’m wondering how easy this is to change to manage checkbox values? I’d like to handle a meta_key with multiple values using checkboxes, like shown in the picture above listing actors and directors.

  7. Hey Rachel, thanks for this spectacularly helpful post. I’d made an attempt at this myself a while back, but hadn’t realised WP used a JS hook to populate the quick-edit fields. Hence, I failed.
    One thing to note, mostly for anyone who might be extending a previous version of a save_posts function: I was updating a parameter-less save_post function, and so had global $post defined within it (rather than utilising a $post parameter). This meant that a standard post edit saved fine, but the quick edit save failed. Removing the global $post definition inside my save_post function fixed it.

  8. _______________________________________
    Hi i put this method to add a ‘displayed price’ in my optical stuff selling site
    after months, I applied this method I felt something left in the quick edit mode. It is that the field won’t populate on my new custom field. That time I thought it just some sort of bug.
    then months have passed and my curiousity growed. I know this can’t be just a bug, there must be a solution of this, so I decided to read every single line of your tutorial very carefully. And find the answer on the….comments. (so bloodly lame to forgot to read the comments previously).
    It comes out that the problem arises from, misplace of the quick-edit.js file. It should have been in my CHILD THEME, not in main MAIN theme… Jesus Christ.
    After fixed all the stuff, and spent like 8 hours for this simply tiny madness bug….I come here again just to say
    You are Gorgeus Rachel…Your Tutor was wonderful ! Now I’ve just fall in love with you <3
    Huge thanks
    Bruce |

  9. Peter Eichhorst Jr. says:

    Great tutorial! I have been successful in getting this to work for a text input. However, could you show me how to ADD another field that is a radio button? Thanks so much!

      1. Nice conversion job Rachel. I love your long function names. My coding standards tests blare at me for anything over 20 characters.

      2. Peter Eichhorst Jr. says:

        Thanks so much Rachel. I see that comment now at the top of this post, guess I missed that.
        The radio button is working for me now.
        However, I realized that the bulk edit is deleting the content of my posts which I believe is unrelated to this modification. Any idea why this would be happening?

        1. Rachel Cherry says:

          On bulk edits, you have to make sure that not only does the field exist, but that it has a value because you dont want to bulk “clear out” a field. You only want to bulk “set” a field. Do you have any other plugins doing bulk edit? Or anything else doing bulk edit? It’s hard for me to troubleshoot without seeing code or knowing more.

          1. Peter Eichhorst Jr. says:

            Well the field that I am referring to is the actual post content, so it seems really strange that this is happening. No other plugins or anything else is doing bulk edit as far as I can tell.

          2. Peter Eichhorst Jr. says:

            Ok, I figured, just thought I’d ask. It is happening on another one of my multisite installations that has a lot of plugins and customization, so it could be a number of things.
            Thanks again.

          3. Peter Eichhorst Jr. says:

            I figured this issue out, it had to do with a function that I had in my code that was not necessary anyways.

      3. Peter Eichhorst Jr. says:

        Rachel, I had another question since you seem to be so knowledgeable about bulk editing. Would you know how to add a filter / hook that gets tapped into the bulk delete function. What I am trying to achieve, is to add custom code that deletes a custom post type (product) for each video that the product is attached to.
        To clarify, i have a product custom post type that has the meta id of each video that is set to be a ppv video. When I delete a single video, I have hooked into the before_delete_post, to delete the attached product. However, when doing this in the bulk actions (force delete being set to on), it does not delete the attached products.

        1. Rachel Cherry says:

          When using the bulk “Move to Trash”, it uses the wp_trash_post() to delete each post. This function includes two actions you can hook into: do_action(‘wp_trash_post’, $post_id) BEFORE the post is deleted and do_action(‘trashed_post’, $post_id) AFTER the post is deleted.

          1. Peter Eichhorst Jr. says:

            Thanks for the response Rachel. I am actually bypassing the bulk “Move to Trash” and replacing it with “Delete Permanently” by setting the following line in wp-config.php
            Therefore, it is only deleting and moving to trash. And like I said, I tried to hook into “before_delete_post” and “delete_post”, but that does not work with the bulk delete.

  10. Unrelated to the tutorial – which looks clear, but I’m still debating whether I have the knowledge and patience to implement, though I definitely have the need! – just wanted to say that I really LOVE your “about” description!

  11. This is a really nice tutorial. I am getting one problem though. When I post my my bulk edit, i just get a -1 on the screen.
    The url looks like this.. i’ll break it down
    I only added a checkbox called _hpd_pm[completed] and that is in the url. I am guessing it has something to do with action2 being -1 but i just cant seem to find anything that helps me. All bulk edit tutorials just come back to your one here. And i have been search for about a week now! Any helpfull ideas?
    Thanks again.

  12. Hi, do you have any idea, why this doesnt work with woocommerce? The quick edit works, but the bulk edit dont. I have the same code working on another site with custom post types, and have used the exact same code in functions.php and in the js files, tripplechecked the field names etc, but bulk edit will not update anything in woocommerce.

      1. Alex Kappel says:

        I’m really interested in making custom fields available for quick edit/bulk editing in WC (Using 2.1+)

  13. Charlie Merland says:

    God, that Javascript part just saved me, thanks a million! Wish I’d found this post a few hours ago, wouldn’t have gone mad trying to update those empty fields… Thanks again Rachel!

  14. Hi Rachel, amazing work. My follow up question is: Would it be possible to order by these custom columns, as it is with Title and Date?

    1. Rachel Cherry says:

      Yes, but it’s a little more complicated. After you make the column “sortable”, you then have to filter the WP query to tell it to sort by your field. I’ll see if I can add something to the tutorial.

      1. Hi Rachel, thx for the reply but I resolved this myself. But if you want to add the code to the tutorial here it is:
        /***CODE START***/
        add_filter(“manage_edit-hs-plugin_sortable_columns”, ‘aff_sort’);
        function aff_sort($columns) {
        $custom = array(
        ‘custom_hs-plugin-komm’ => ‘custom_hs-plugin-komm’,
        ‘custom_hs-plugin-aktiv’ => ‘custom_hs-plugin-aktiv’
        return wp_parse_args($custom, $columns);
        add_filter( ‘request’, ‘komm_column_orderby’ );
        function komm_column_orderby( $vars ) {
        if ( isset( $vars[‘orderby’] ) && ‘custom_hs-plugin-komm’ == $vars[‘orderby’] ) {
        $vars = array_merge( $vars, array(
        ‘meta_key’ => ‘custom_hs-plugin-komm’,
        ‘orderby’ => ‘meta_value’
        ) );
        return $vars;
        add_filter( ‘request’, ‘aktiv_column_orderby’ );
        function aktiv_column_orderby( $vars ) {
        if ( isset( $vars[‘orderby’] ) && ‘custom_hs-plugin-aktiv’ == $vars[‘orderby’] ) {
        $vars = array_merge( $vars, array(
        ‘meta_key’ => ‘custom_hs-plugin-aktiv’,
        ‘orderby’ => ‘meta_value’
        ) );
        return $vars;
        /***CODE END***/
        Again thx for e great tutorial 🙂

  15. Kathy_Darling says:

    Hi Rachel. Thanks for this, it was a huge help. I’m curious that there isn’t a wp_verify_nonce, or check_admin_referer(). Is this not needed in bulk edit? Is it covered somewhere else by WP? As soon as I add check_admin_referer(‘bulk-posts’); to the save callback, it stops saving.

    1. Rachel Cherry says:

      There is a verify nonce for Quick Edit but not for Bulk Edit. I looked around to see if WordPress does anything and it appears that they don’t nor do they make it very easy to add one.

  16. I have a question. So can I actually bulk edit a lot of pages content with this tutorial or it just edits the columns? I have about 500,000 pages that need rewording in the content part of the post. How would you advice someone to go about editing such a bulk with a pluggin. Thanks in advance.

      1. Thanks comprock but I do I have Search Regex installed. The problem is that the pages I want to bulk edit are neither in posts nor pages. They are in services and search regex doesn’t recognize services as an editable region for some reason.

    1. Rachel Cherry says:

      You won’t be able to bulk edit post content with this tutorial. This bulk edit is more for custom fields and post meta, i.e. short snippets of info. You’re going to need something along the lines of what comprock suggested. Does that plugin only search the ‘post’ and ‘page’ post types and not custom post types? If so, that’s a bummer. I found this support topic on its forum, though, that might help you out.

  17. hi … tanx for this post … but i want add and edit custon feileds to quick edit … is that imposible…!!!?

    1. Michael Cannon says:

      It’s possible, just read the new tutorial linked to by Rachel above. If you’re not into coding your own, there’s Custom Bulk/Quick Edit in WordPress plugins.

Leave a Reply to Alex Kappel Cancel reply

Your email address will not be published. Required fields are marked *

Login to WordPress