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 ); }


6

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

Actually there is already in their API something for this: icl_object_id(ID, custom_taxonomy_name, return_original_if_missing,language_code) Works like a charm. More read on this : Language Dependent IDs


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

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 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 ...


3

I've done it with this bit of code: global $wpdb; $posts = get_posts(array('post_type'=>'...', 'posts_per_page'=>-1)); foreach($posts as $post) { $wpdb->update('wp_icl_translations', array('language_code'=>'es'), array('element_id'=> $post->ID)); }


3

For the language filter from WPML to take effect you have to allow filters in get_posts. Default this is off. You can add suppress_filters=0 to your get_posts args and it should work. See: http://codex.wordpress.org/Template_Tags/get_posts#Parameters <ul id="archive-list"> <?php $args = array( 'suppress_filters' => false, 'numberposts' =>...


3

I had this problem with querying on two custom post types, using WP_Query. I had no problem querying for one type or the other in the array, but not both at the same time. Did not work: $args = array( 'post_type' => array('custom_type_1','custom_type_2'), 'posts_per_page' => 4 ); Did work: $args = array( 'post_type' => array('...


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'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

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

Don't use query_posts for secondary loops. This is just a general "best practices" recommendation and not the cause of your problem. When you register the post type make sure 'public' => true Put the following in a template somewhere and report back the output. It will return the object of each registered custom post type and will verify whether or not ...


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

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

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

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

First of all i wouldn't use phpmyadmin for a database that large. Use something like Sequel Pro its free and easy to use. Second if you dont want the tables that WPML Created and you have removed the plugin from your site you can remove the tables that it creates. Upload the sql to a new database on your local machine and remove all this tables for each ...


2

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 ...


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

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')) { ...


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