Theme Menus Links (CPT Pages) shown for all languages
-
Hi Chouby. I tried the modification you kindly provided to fix the wpsc-product posts being shown for all languages situation:
if (function_exists('pll_get_post')) // test a Polylang function to avoid ugly fatal error at Polylang upgrade add_action('parse_query', 'pll_wpsc_parse_query'); function pll_wpsc_parse_query($query) { if (is_page( pll_get_post(wpsc_get_the_post_id_by_shortcode( '[productspage]' ) ))) { global $polylang; $polylang->choose_lang->set_lang_query_var($query, $polylang->curlang); } }
It does filter the wpsc-product posts to show only the ones created for the current language, but if I select a different page from the theme’s main menu links (e.g. Your Account, Transaction Results, Checkout, Contact), it continues to show wpsc-product posts in the current language as page content after clicking any of the menu links, instead of the expected content. Only if I click “Home”, I get to see something different than the wpsc-product posts. Another issue is that while I click a theme menu link that points to a CPT page (products page, checkout, etc.), it shows all the theme’s main menu links in all languages, instead of only showing the ones that apply for the current language.
I tried the following:
function p4we_wpsc_parse_query($query) { global $polylang; $polylang->choose_lang->set_lang_query_var($query, $polylang->curlang); } add_action('parse_query', 'p4we_wpsc_parse_query');
And this allows me to see the expected content after clicking any menu link (Home, CPT pages, etc.). Only the wpsc-products posts created for the current language are shown in the products CPT page, as expected, but now the theme’s main menu links are shown in all languages and this even happens when viewing the Home page, as you may see circled in yellow in the following image:
Main menu links shown for all languages.
Is there something that you may recommend to fix this situation?
Thank you, Chouby!
- The topic ‘Theme Menus Links (CPT Pages) shown for all languages’ is closed to new replies.