9

The instance of this class is made global by WPML, so this should work: if ( ! empty ( $GLOBALS['sitepress'] ) ) { add_action( 'wp_head', function() { remove_action( current_filter(), array ( $GLOBALS['sitepress'], 'meta_generator_tag' ) ); }, 0 ); }


7

Assuming $new_lang holds the desired two letter language code (e.g. 'fr'), you can do this: global $sitepress; $current_lang = $sitepress->get_current_language(); //save current language $sitepress->switch_lang($new_lang); //...run query here; if you use WP_Query or get_posts make sure you set suppress_filters=0 ... $sitepress->switch_lang($...


5

You don’t have to make anything special for WPML, using the regular translation code should be enough. See I18n for WordPress Developers in the Codex. Code preparation style.css Add Text Domain and Domain Path to your theme’s style.css. Example: /* * Theme Name: My awesome theme * Text Domain: my_awesome_theme * Domain Path: /languages */ ...


4

I'm not really up to date on WPML and how it handles translations, but my general understanding is that in most cases it simply creates duplicate entries for each language and links them together with the "original". However, I recently hade a similar problem where I needed the ability to add a "pluralized" version of the term names (as opposed to the ...


4

Polylang seems to be a direct alternative to WPML. From the plugin description: Polylang allows you to create a bilingual or multilingual WordPress site. You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation of a post, whether it is in the default language or not, is ...


4

Within the code, can you see any syntax like either of the following? __( 'Hello, dear user!', 'my-text-domain' ) _e( 'Your Ad here', 'my-text-domain' ) That is, strings starting with __ (double underscores) or _e. If so, where the above says my-text-domain, you should find the name of your text domain.


4

I'm working on a similar solution right now - the website must have language codes in all URLs (except the default language), but only pages are translatable in a way WPML/Polylang plugins do it. For news (blog) we just show posts in particular language (they are separate, not translations of each other). All the other content is mixed in all languages. Also,...


3

Actually Wordpress lacks a real function to get posts by slug/post-name. But you can use get_page_by_path() for it so you don't have to use a custom query: if(function_exists('icl_object_id')) { $post = get_page_by_path('your-slug'); $id = icl_object_id($post->ID,'post',true); $link = get_permalink($id); } The only difference here is that you ...


3

I've found what was going on, so I'm going to answer it for future reference, as it's a common issue without clear solution. TL;DR: If the WPML language which's not redirecting has a country code (eg. en-US instead of en) then you probably have the same bug. Jump to section "How to fix it". The Problem The problem arises at the redirection javascript ...


3

NOTE: I'm not giving a full answer to your question but trying to give some snippets that may help in WPML-based project. I've used this function: function get_the_translated_ID($id){ if (!class_exists('sitepress') return $id; global $sitepress; $type=get_post_type($id); return icl_object_id( $id, $type, false, $sitepress->...


3

You can use the global $wp_locale to get the month translated in each language. You just need to get the month number (01 to 12) from the Acf field. You have the functions in the WP_Locale class get_month() and get_month_abbrev() global $wp_locale; $month = $wp_locale->get_month(04); // Output april in english $month_abbrev = $wp_locale->...


2

Thanks for that mike23, was a lifesaver for me today. However that exact code didn't work for me, I did have to do some modifications in order to get it to work in my situation which may be due to a newer version of the WPML plugin. I had to change: $original_ID = icl_object_id( $post->ID, 'post', false, 'en' ); to: $original_ID = icl_object_id( $post-...


2

My solution was to register the custom post types on the site where I'm calling it from, then in WPML's settings set them to translate. This is in WPML -> Translation Management -> Multilingual Content Setup, down at the bottom. I assume it works by tricking WP into using that site's rewrite/translate rules when it doesn't have the proper info from ...


2

A .mo file is the machine readable Version of a .po file, which in turn holds the translation of a .pot file. Hence, the latter is what you want to have in the first place. And if it is your theme you want to localize, you certainly do not need a random plugin's simplified Chinese .mo file... Using either, poedit, any other gettext application or the ...


2

You cannot translate text you don’t know. The translator must know the text before it was submitted – impossible. The only solution is: add all language strings manually for each sub site.


2

WPML offers this feature. You can set it in the Languages adminsection, at the option Browser Language Redirect.


2

WPML has a pretty good documentation on how to make a theme compatible. Most of the time, all themes should work out of the box with WPML if the theme designer did follow the wp standards for internationalization. If you don't get further with that link and have any concrete problem we can help you with, please add the details of what goes wrong and how ...


2

To translate something in your js you can use wp_localize_script() really handy : $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array );


2

Well, it's pretty clear, why this problem occurs. Let's look at wp_insert_term documentation: Return Values (array|WP_Error) The Term ID and Term Taxonomy ID. (Example: array('term_id'=>12,'term_taxonomy_id'=>34)) As you can see, on success this function returns array. But... If any error occurs, it will return an object of WP_Error type. So... ...


2

The problem your GET param is using the same name as the query var for your custom post type. $link = $link_aqui_se_sirve.'?'.$establecimientos_cpt_name.'='.$tax->slug; With that URL, WordPress is expecting the value of the $establecimientos_cpt_name parameter to be a post slug. Instead you are giving it a taxonomy slug. This will give you a 404 unless ...


2

The way WPML works is that you have a translation or a duplication across all languages of your content, that way each language has access to all content. You can duplicate or better yet batch duplicate any content that you need for all languages. WPML makes it easy to maintain that content across all languages. When you update your posts in the default ...


2

I have developed pages in that manner and if you are using WordPress functions and follow WP Codex it is same situation as if you developed custom page template. Just follow I18n for WordPress Developers and you will be fine.


2

Try to check on DB level. This SQL should give a list of all spam comments (which I assume skräpposter means): SELECT * FROM `wp_comments` WHERE `comment_approved` = 'spam'; If the SQL gives 0 lines, the issue is with WordPress counting those comments, but in fact there are none. If the SQL gives a list, the issue is with the listing of those comments. It ...


2

So I've made it work. The problem was not with the filter but with tax query. Here is the solution for those who might be interested. <?php // I check the lang query var if it's empty we'll display all languages $langGet = get_query_var('lang', 'all'); ?> /* Then have my form to filter posts */ <form action="<?php echo get_permalink( ...


2

It's not a good practice to use post name to style your page. Maybe you can use template page. But if you still want to do it, you can do something like this: function add_default_language_slug_class( $classes ) { global $post; if ( isset( $post ) ) { $default_language = wpml_get_default_language(); // will return languague code of your ...


2

The problem was actually the pages having "no language" and WPML seems to hate this. So I just deleted all those pages and re-inserted them with the proper WPML language attributes: // (...) // Create the page $customPage['id'] = wp_insert_post( $pageParams ); // Check if WPML parameters are needed if (has_action('wpml_set_element_language_details')) { ...


1

I did it like this. Used WPML filter and returned default url rather than filtered one. function custom_wpml_home_url( $home_url, $url, $path, $orig_scheme, $blog_id ) { return $url; } add_filter( 'wpml_get_home_url', 'custom_wpml_home_url', 99, 5 );


1

I found that it required removing 4 filters/actions to undo WPML's home_url modification. Since I didn't know what else this might break, I ended up changing my site's logo to use site_url() which in my case was the same, but not changed by WPML. function disable_things(){ remove_filter( 'page_link', array( $this, 'permalink_filter' ), 1, 2 ); ...


1

Because you are hardcoding the link, you will need to use icl_link_to_element() function and wrap any text you want to translate inside a gettext function: <?php icl_link_to_element( 'ID_of_your_news_page', 'page', '<h4>' . __('News') . '</h4>' ); ?> This way you will get the correct version of the link based on the current language with ...


1

Use WordPress i18n functions. Normally good plugins are translation-ready, and you should create your translation files for that plugins (if not already present). Explain how to is too much for this answer, start looking at Codex page linked above, search Google and also have a look here. If a plugin is not translation-ready use another plugin or modify it ...


Only top voted, non community-wiki answers of a minimum length are eligible