I recently imported large number of custom posts into wordpress. all works fine, except one taxonomy which is imported, but not show at the front end, until i click on every post "update" button. I have 810 posts and this is not a solution...

i think it should be the way to run MYSQL command to force all post update without making any changes. Please help me with command, i searched for plugins and cannot find anything suitable

Thank you

  • Small hint, the UI have also a bulk action to update all posts. You should change the list of all posts, right top screen options for the count of posts. After this use the bulk action to update all posts, there are listed.
    – bueltge
    Commented Feb 20, 2018 at 9:05
  • Sorry, i am not a programmer... if you mean bulk action on admin screen, it doesn't work. the only think works for me is going to every post and pressing "update" button
    – AlexPTY
    Commented Feb 20, 2018 at 9:14
  • Yes, it is for users, without coding know how. See on the wp-admin/edit.php and select the edit option int the bulk options, select also all posts and click Apply. Now the first selected post open the quick edit view and you can change data, that well update in all selected post after update.
    – bueltge
    Commented Feb 20, 2018 at 9:35
  • as i said, it doesn't work from the bulk action, only every post "update" button works
    – AlexPTY
    Commented Feb 20, 2018 at 9:50

3 Answers 3


There are 2 ways that you could do this. The first and more difficult is to write a program, the other is to do a bulk update. Why do difficult when easy way will work equally well? and especially as this is a once-off requirement

The easy way:

  1. In the admin dashboard, select the view with all posts for your custom type
  2. Select all the posts (tick them) - You can see more posts by clicking 'Screen Options' at the top right of the view and increasing the number of items per page
  3. Click the down arrow next to 'Bulk Actions' and select edit
  4. Press 'Apply' - you will get a screen with a selection of changes you can make
  5. Make some change, like add a tag or change author (whatever)
  6. Press 'Update'

That should do it.

The 'difficult' way:

In case anyone wants to use the code solution, you can add the code below to the functions.php file in your child theme.

function my_update_posts() {
    //$myposts = get_posts('showposts=-1');//Retrieve the posts you are targeting
    $args = array(
        'post_type' => 'post',
        'numberposts' => -1
    $myposts = get_posts($args);
    foreach ($myposts as $mypost){
        $mypost->post_title = $mypost->post_title.'';
        wp_update_post( $mypost );
add_action( 'wp_loaded', 'my_update_posts' );

Remember to run this only once and then remove it or comment out the add_action line otherwise it will run every time a new page is loaded.

I included this option in case anyone wants a start template for updating all post titles or some other property in all posts.

  • 2
    Or use -1 for all posts instead of the 1000 in this example.
    – bueltge
    Commented Feb 20, 2018 at 11:20
  • 1
    Easy way doesn't work. Quick Edit doesn't work as i said earlier, only full edit of the post works. I do not know why, maybe because this button trigger "publish" command instead of the "update". Is there a way to to force the "publish" the posts instead of "update"?
    – AlexPTY
    Commented Feb 20, 2018 at 11:38
  • 1
    nop, doesn't work. i think i will manually edit all posts tomorrow, it will take couple of hours, but i already spent half of the day looking for solutions. Thank you everyone
    – AlexPTY
    Commented Feb 20, 2018 at 12:44
  • 1
    Same as @AlexPTY this code must be similar to the bulk update. Has no effect. Commented Mar 27, 2020 at 19:51
  • 1
    you can drop the line $mypost->post_title = $mypost->post_title.'';. Also, if you use wp_insert_post( $mypost ); it's a tiny bit faster. (it will not insert a new post because ID is the same)
    – Jules
    Commented Dec 24, 2020 at 12:27

First: Get all posts using get_posts or WP_Query.

$query_posts = new WP_Query( array(
    'nopaging' => true,
) );

Second: Do loop for posts and use wp_update_post() for each post and set ID parameter.

while ( $query_posts->have_posts() ) :
    wp_update_post( array(
        'ID' => get_the_ID(),
        'post_content' => get_the_content(),
    ) );

Place this code to init action or header/footer. Update page once and remove code. Place this code in functions.php and all your posts will be updated on page reload.

add_action( 'init', function () {
    $query_posts = new WP_Query( array(
        'nopaging' => true,
    ) );

    while ( $query_posts->have_posts() ) :
        wp_update_post( $post );
} );
  • Thank you Maxim, but this code deleted content of all my posts on refresh. i will restore everything and try other solution
    – AlexPTY
    Commented Feb 20, 2018 at 11:31
  • set content from your current post to post_content in wp_update_post() function. wp_update_post( array( 'ID' => get_the_ID(), 'post_content' => get_the_content() ) ); Commented Feb 20, 2018 at 11:33
  • sorry, i am not a programmer. i can only copy/paste ;)
    – AlexPTY
    Commented Feb 20, 2018 at 11:48
  • Edited my post. Commented Feb 20, 2018 at 11:50
  • sorry, it just erases the content of the post on refresh.
    – AlexPTY
    Commented Feb 20, 2018 at 11:56

For any future interested people: to bulk update posts one by one, you can use chrome extension web scrapper that will automatize clics on update button on every post.

  • 1
    how did you get it done? I'm trying to use it but nothing works as expected
    – moeses
    Commented Feb 4, 2021 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.