Hello,
I have a view showing user's posts. This view filters the results based on the post language.
When view 'opens' in an English page, then only English posts are shown while view 'opens' in a Greek page only Greek posts are shown?
How will I override this? I want view to print all user's posts regardless the page language.
Thank you!
Hello,
I assume you are using WPML plugin to translate the posts.
If it is, this is expected result, Views will output posts of specific language by current page.
You might consider to use display a language switcher, after user click the language links, Views will output posts of specific language.
Yes, I use WPML.. Are you sure that this is the default behaviour? It sounds very strange..!
Yes, I am sure that it is default behavior, using WPML plugin, in Greek page, Views will output only posts in Greek language.
Could I have a page which is untranslated in order to have posts of all languages? Is this possible?
It sounds very strange to me not to have posts of all languages in a toolset view.
Thank you!
For the question:
Could I have a page which is untranslated in order to have posts of all languages?
As I mentioned above, there isn't such kind of feature within Views plugin, if you agree, I can escalate this issue as a feature request.
Currently, I suggest you display link of post translations, for example:
1) Create a custom shortcode, put below PHP codes into your theme file functions.php:
function wpml_post_languages_in_loop() {
$post_trid = apply_filters('wpml_element_trid', NULL, get_the_ID(), 'post_' . get_post_type());
if (empty($post_trid)){
return;
}
$active_langs = apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0' );
$translations = apply_filters('wpml_get_element_translations', NULL, $post_trid, 'post_' . get_post_type());
if (is_array($translations) && !empty($translations)) {
$langs = array();
foreach ($translations as $translation) {
if (is_object($translation) && isset($active_langs[$translation->language_code]) && $translation->element_id != get_the_ID()) {
$langs[] = '<a href="' . apply_filters('wpml_permalink', ( get_permalink($translation->element_id)), $translation->language_code) . '"><img src="' . ICL_PLUGIN_URL . '/res/flags/' . $translation->language_code . '.png" width="18px" height="12px"></a>';
}
}
if (!empty($langs)) {
return __('This post is also available in', 'wpml') . ': ' . implode(' ', $langs);
}
}
}
add_shortcode('post_translation_links', 'wpml_post_languages_in_loop');
2) Edit your post view, in section "Loop Editor", within View's loop, display above shortcode, like this: [post_translation_links]
Thank you Luo!
Yes, please escalate this issue as a feature request.