WPML: how to show places in default language when translation is missing
This topic contains 17 replies, has 3 voices, and was last updated by Stiofan O’Connor 10 years, 1 month ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: WPML
-
AuthorPosts
-
September 21, 2014 at 12:54 pm #16022
The title gives it pretty much away. How can that be achieved for listings and detail pages?
So if there is for example mostly content in the default language, the home page and other listings should display the posts in the default language for those posts that are not translated.I don’t know if it is related, but after I installed WPML, the virtual pages did not show up anymore in the pages section. I opened the pages directly via entering their id that I found out in the database, set the language to my default language and resaved them. Then I added translations to them. After that, they show up again in the pages section.
September 21, 2014 at 1:37 pm #16027Hi wu,
I am sure there is a setting in wpml somewhere for that, have you found this and it’s not working or have you just not found this setting?
Stiofan
September 21, 2014 at 1:58 pm #16031All that I found is the switch that decides if places get translated or not.
In both options, the listings only display places with the current languages.September 21, 2014 at 2:11 pm #16033as far as i know the setting is here:
WPML>Languages>Language switcher options>How to handle languages without translation>>Stiofan
September 21, 2014 at 2:24 pm #16034I tried both settings, but got the same result: it only shows places in the current language and nothing if there is no translation for the current language.
September 21, 2014 at 2:55 pm #16039Hi wu, i tried and got the same result, i don’t use WPML much and i’m not sure if this is the designed functionality, can you maybe ask on the wpml forum?
Stiofan
September 22, 2014 at 3:59 pm #16143What I found out so far, is that there is a setting called “Blog posts to display” that does exactly what I need, but only for blog posts and not for other post types. As I understand, it would require custom coding for other post types.
Here I found an example for that:
/* WPML * Display default content on missing languages */ add_filter('icl_ls_languages', 'wpml_ls_filter'); function wpml_ls_filter($languages) { global $sitepress; $default_url = $languages[$sitepress->get_default_language()]['url']; foreach($languages as $lang_code => $language){ if($languages[$lang_code]['missing']==1){ $languages[$lang_code]['url'] = $default_url; } } return $languages; }
But in that form it does not work.
Maybe I need to attach it to another hook?Or would some customization of the query like in that thread be needed?
September 22, 2014 at 4:22 pm #16148Hi,
this looks like a good question for WPML forum?
Thanks.
September 24, 2014 at 11:26 am #16376The guys over there are asking for the code that displays the posts.
I think it is code in geodirectory-functions/listing_filters.php, but I am not sure about that. Could you please point me to the correct location?September 24, 2014 at 1:22 pm #16384When I replace:
$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
with:
$where .= " AND icl_t.language_code = '$default_lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
in geodir_default_where(), posts are showing up only in the default language only, so this seems to be the right place.
Is this function controlling all GeoDirectory posts on all pages, or is there more code to look out for?
September 24, 2014 at 3:46 pm #16398That is correct for listings pages. For widgets like popular post view these are in geodirectory/geodirectory-widgets.
Thx
September 29, 2014 at 4:35 am #16833The support over there is telling me to add an “OR” statement to the “WHERE” part to include the default language or the translations.
I tested this and found out that the place is showing up twice if there is a translation.
The support now suggests to filter that out in a while loop.
What is your opinion about this?
I am almost sure this will collide with pagination, “num_rows” and “LIMIT” in the query, as the query will return the wrong number of rows in some cases.
What can I tell them?September 29, 2014 at 8:59 am #16849This reply has been marked as private.September 29, 2014 at 1:36 pm #16858This reply has been marked as private.September 30, 2014 at 1:30 pm #16976This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket