Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client has a site with hundreds of pages, some of which are not translated, some need updates, and some are up to date in terms of translation. The client is looking for a way to update all translations at once, instead of updating each page individually for each language.
Solution:
We informed the client that there is no built-in option in WPML to update all translations at once. However, if the client is translating content using the WordPress Editor and not relying on the Advanced Translation Editor, we provided a code snippet that could be used as a workaround.
First, ensure to back up the site and database. Then, add the following code to the

functions.php

file of the theme:

add_action( 'admin_init', 'save_all_posts_on_refresh' );
function save_all_posts_on_refresh() {
  global $pagenow;
  if ( $pagenow == 'edit.php' ) {
    $args = array(
      'post_type' => array('page', 'post'),
      'numberposts' => -1
    );
    $all_posts = get_posts( $args );
    foreach ( $all_posts as $single_post ) {
      wp_update_post( $single_post );
    }
  }
}

After executing this code by reloading the Posts List on

/wp-admin/edit.php

, remember to remove the snippet from the

functions.php

file.

Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If this does not resolve your issue, we highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Andreas W. 6 months, 3 weeks ago.

Assisted by: Andreas W..

Author Posts
April 23, 2024 at 8:48 pm #15558249

technicalS-2

I have a site with hundreds of pages. Some are not yet translated, some need updates, and some are up to date in terms of translation.

Instead of clicking each language for each page, and clicking update, is there a way to do these all at once? Is there a single "update all pages" type button somewhere?

April 24, 2024 at 4:03 am #15558562

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for reaching out!

Unfortunately, we do not have such an option.

The WPML Translation Management will update itself once you complete the translations and then again once the original content is updated.

The only way would be to use the "Translate everything automatically" option while having credits for automatic translations available.

Are you translating all your content with the WordPress Editor or are you using the WPML Translation Editor?

----

A suggestion, in case you translate all your content with the WordPress Editor and you do not rely on the features of the Advanced Translation Editor:

IMPORTANT: Please do only proceed after taking a backup of your site and database:

You could place this code inside the functions.php file of your theme, then go to the Posts List on /wp-admin/edit.php and reload the page. This will save all posts and all pages in all languages:

// Add a function to the admin_init hook
add_action( 'admin_init', 'save_all_posts_on_refresh' );
 
// Define the function to save all posts on refresh
function save_all_posts_on_refresh() {
  // Check if the current page is the posts page
  global $pagenow;
  if ( $pagenow == 'edit.php' ) {
    // Get all the posts
    $args = array(
      'post_type' => array('page', 'post'),
      'numberposts' => -1
    );
    $all_posts = get_posts( $args );
    // Loop through all the posts and update them
    foreach ( $all_posts as $single_post ) {
      wp_update_post( $single_post );
    }
  }
}

After that, remove the snippet from the functions.php file.

Best regards
Andreas