Support » Fixing WordPress » Update all posts at once using wp_update_post

  • Although many questions appear to be the same, the problem is that I can’t get the posts’ contents to be updated at once. The wp_update_post doesn’t apply to all posts and doesn’t even update the post itself using the bulk-edit, however, the code works fine when I update the post from inside the post. Here’s my code. I would appreciate a good help.

    if ( ! wp_is_post_revision( $post_id ) ){
        // unhook this function so it doesn't loop infinitely
        remove_action('save_post', 'my_function');
        wp_update_post(// We update the french post
        array (
          'ID' => $post_id,
          'post_type' => 'letters',
          'post_content' =>
          $postTitle . ' ' .
          $fnlterms
    ));
        add_action('save_post', 'my_function');
    }
    
    }
    add_action('save_post', 'my_function');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Update all posts at once using wp_update_post’ is closed to new replies.