Problem: The client needs to automatically create a duplicate of each Spanish (Spain) page/post for Spanish (Mexico) on their multilingual site, but only for certain pages. Solution: We recommend using the WPML hook for duplicating posts automatically. First, ensure you back up your site and database. You can implement the following code in your theme's functions.php file or a custom plugin:
This script checks if a post is a new or updated Spanish post and duplicates it for Spanish (Mexico) if no translation exists. Modify the condition inside the function if you want to limit this behavior to specific post types. For more details on the hook used, visit WPML admin make post duplicates.
If this solution does not apply to your case, or if it seems outdated, please check the related known issues, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If further assistance is needed, we encourage you to open a new support ticket.
Problem: The client wants the language switcher in the nav bar to display the name of the other language instead of the active language. The site uses Gutenberg blocks, and the switcher currently shows only two letters representing the active language (German), but the client wants it to display the name of the other language (French). Solution: We recommend two methods to achieve this: Method 1: Hide the current language using CSS 1. Edit the Language Switcher block. 2. Set the "Layout" to list. 3. Add the following CSS in the custom CSS section of the theme:
Method 2: Add language switcher using shortcode 1. Go to the WPML >> Languages page. 2. Enable the Custom Language Switcher. 3. Replace the language switcher block with a shortcode block and use the following shortcode:
If these solutions do not resolve your issue or if they seem outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.
Problem: You are using WP-CLI to list all media IDs in the trash across all languages but the command only returns media IDs for the main language. Solution: We have identified two potential workarounds to include media IDs from all languages: 1) Use the WP-CLI parameter
--suppress_filters=true
which allows the command to work across all languages. 2) Use the parameter
--url="https://yourwebsite.com/en"
to force WP-CLI to work in the language based on the URL.
Additionally, our 2nd Tier Support suggests modifying the code in
function with the following code to include a condition that checks for the 'lang' parameter in the query:
public function posts_where_filter( $where, $query ) {
if ( $query === null || $this->where_filter_active( $query ) === false ) {
return $where;
}
$requested_id = isset( $_REQUEST['attachment_id'] ) && $_REQUEST['attachment_id'] ? $_REQUEST['attachment_id'] : false;
$requested_id = isset( $_REQUEST['post_id'] ) && $_REQUEST['post_id'] ? $_REQUEST['post_id'] : $requested_id;
$requested_id = (int) $requested_id;
$default_language = $this->sitepress->get_default_language();
$post_language = $this->post_translations->get_element_lang_code( $requested_id );
if (isset($query->query["lang"])) {
$post_language = $query->query["lang"];
$requested_id = "1"; //hack needed because then $current_language will not get the $post_language, but will call for get_current_language
}
$current_language = $requested_id && $post_language ? $post_language : $this->sitepress->get_current_language();
$condition = $current_language === 'all' ? $this->all_langs_where() : $this->specific_lang_where( $current_language, $default_language );
$where .= $condition;
return $where;
}
Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If these solutions do not resolve your issue, please open a new support ticket at WPML support forum.
Problem: You have created a custom post type (CPT) with the slug 'event' using the ACF Pro plugin and defined a custom archive slug 'events'. You have translated the base default slug 'event' to 'événement' in French via WPML > Settings > Post Types Translation, but you are unable to find where to translate the archive slug. Solution: Currently, WPML does not support the translation of custom slugs set in the
has_archive
option for custom post types. You can read more about this limitation here. We recommend enabling the archive option and leaving the slug field empty for custom post types created with ACF. This approach uses the default slug, and when you switch languages, the translated slug set in "WPML > Settings > Post Type Translation" will display.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please open a new support ticket at WPML support forum.