Manage WordPress Posts Using Bulk Edit and Quick Edit

About Rachel Carden

Rachel Carden is a High Ed Web Developer with a fondness for WordPress. She's also a puzzle fiend who gets way too excited about programming and problem solving. And you thought you were a nerd.

80 Comments

  • Jeff Parsons says:

    Totally awsum Rachel, thank you!

    Just exactly what I was looking for.  Nicely documented.

  • 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?

    • rachelcarden says:

      Hmm.. I don’t understand what you mean by “normal” postdate. Could you elaborate a little?

      • 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 !!

        • rachelcarden 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 =)

          • Amrani says:

            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 :)

  • 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?

    • rachelcarden 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.

      • 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 :)

        • comprock says:

          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`.

  • Poulomi says:

    Thanks a ton! Your post has been so useful ! :D

  • something wrong with this:
       
    var $post_ids = new Array();
           $bulk_row.find( ‘#bulk-titles’ ).children().each( function() {
              $post_ids.push( $( this ).attr( ‘id’ ).replace( /^(ttle)/i, ” ) );
           });
       

    The $post_ids is empty

    • will says:

       I got the same problem when I tried to bulk edit the posts

      • will says:

        Any help with this block of codes to resolve the bulk edit problem is greatly appreciated!

        • rachelcarden says:

          Will and Marco, can you let me know which version of WP you’re running? And any other info that might help me troubleshoot, like plugins you’re running or what theme you’re using? What version of jQuery you’re running? Thanks!

    • rachelcarden says:

      Marco, can you let me know which version of WP you’re running? And any
      other info that might help me troubleshoot, like plugins you’re running
      or what theme you’re using? What version of jQuery you’re running?
      Thanks!

      • will says:

         Hi Rachel,
          I am using WP 3.2.1.  I installed the codes as you have instructed in one of the comments, but I got a 403 error when I bulk edited the posts:
        Forbidden

        You don’t have permission to access edit.php
        on this server.

        Additionally, a 404 Not Found
        error was encountered while trying to use an ErrorDocument to handle the request.
          Quick edit works fine, but I just have a problem with bulk edit.  Bulk edit other default settings such as author, comments, and status also worked.  And again, I just got the error with bulk edit the custom field (i.e. release date).
          My site uses jQuery 1.6.1 and I am using Classipress theme.
          Any help is greatly appreciated!
        Thanks,
        Will

  • gomymusic says:

    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?

    Thanks,

    • rachelcarden 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.

  • gomymusic says:

    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.

    Thanks.

    • rachelcarden 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();

  • Nikita says:

    Great Tutorial, Thank You!

  • […] names off the top of my head in five minutes flat: Rachel Carden wrote one of the best dev tutorials I’ve seen recently; Rachel Baker created a Bootstrap theme for WordPress (not as easy as […]

  • Miguel says:

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

  • Eero says:

    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.

  • parikshit janghu says:

    I have become fan of you…..

    You are simply amazing ” Like a super girl ” .

  • Lawrie Malen says:

    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.

    • rachelcarden says:

      Thanks for pointing that out. When I migrated sites a little while ago, I forgot to migrate those files. It’s working now!

  • brucetarigan says:

    _______________________________________

    Hi i put this method to add a ‘displayed price’ in my optical stuff selling site http://cdkosong.com

    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 | http://cdkosong.com

  • rachelcarden says:

    Nice! Good luck!

  • 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!

    • comprock says:

      Peter, search for `’radio’` at https://github.com/michael-cannon/custom-bulkquick-edit/blob/master/custom-bulkquick-edit.php to see how I’m handling radio buttons.

    • rachelcarden says:

      Peter,

      I have tweaked the code and converted it to plugin format so I can better test in my development environment and keep it up to date. I put the plugin on Github if you want to check it out: https://github.com/bamadesigner/manage-wordpress-posts-using-bulk-edit-and-quick-edit

      I also added a radio custom field and a select dropdown field. Hope this helps!

      • comprock says:

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

      • 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?

        • rachelcarden 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.

          • 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.

          • Peter Eichhorst Jr. says:

            It is happening without any modifications to the code and even on regular posts too.

          • rachelcarden says:

            I don’t know what to tell you there. That’s pretty odd. :/

          • 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.

          • 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.

      • 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.

        • rachelcarden 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.

          • 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

            define(‘EMPTY_TRASH_DAYS’,0);

            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.

  • […] Customize BulkEdit and QuickeEdit […]

  • Kevin Smith says:

    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!

  • Heinrich says:

    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
    ?s=
    post_status=all
    post_type=project_management
    _wpnonce=4427b42b0f
    _wp_http_referer=%2Fwp-admin%2Fedit.php%3Fpost_type%3Dproject_management
    action=edit
    m=0
    paged=1
    mode=list
    tax_input%5Bhpd_pm_clients%5D%5B%5D=0
    post_author=-1
    comment_status=
    _status=-1
    tax_input%5Bpost_tag%5D=
    _hpd_pm%5Bcompleted%5D=1
    bulk_edit=Aktualisieren
    post_view=list
    screen=edit-project_management
    post%5B%5D=19
    post%5B%5D=18
    action2=-1

    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.

  • Conny says:

    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.

  • 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!

  • Hasan says:

    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?

    • rachelcarden 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.

      • Hasan says:

        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***/
        /*
        * ADMIN COLUMN – SORTING – MAKE HEADERS SORTABLE
        */
        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);
        }
        /*
        * ADMIN COLUMN – SORTING – ORDERBY
        */
        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 :-)

  • 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.

    • rachelcarden 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.

  • Aisha Mina says:

    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.

  • tojihi.com says:

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

Leave a Reply

Want to give a little love and support my work? Donate