filip.jnc
Forum Replies Created
-
Forum: Plugins
In reply to: [Polylang] Untranslated taxonomies/custom taxonomiesI changed some bits of code in this plugin to redirect me to ?lang=ru of the same article if no translation is found and query the default article. It’s not a permanent fix, but I hope Polylang gets the future of displaying default category lists/posts/whatever if no translation found. Cheers.
Ok this is my em-events.php that makes Events Manager scan for “CONTENTS” in the russian parallel page: https://pastebin.com/ZEMhmFfL (the lines I changed are marked with //core_changed//polylang)
This works for Events and -Categories but now it still displays CONTENTS when you open a translated category. I noticed this is due to the file /classes/em-category-taxonomies.php:function the_content($content){ global $wp_query, $EM_Category, $post, $em_category_id; $is_categories_page = $post->ID == get_option('dbem_categories_page'); $category_flag = (!empty($wp_query->em_category_id) || !empty($em_category_id)); if( ($is_categories_page && $category_flag) || (empty($post->ID) && $category_flag) ){ $EM_Category = empty($wp_query->em_category_id) ? em_get_category($em_category_id):em_get_category($wp_query->em_category_id); ob_start(); em_locate_template('templates/category-single.php',true); return ob_get_clean(); } return $content; }
There’s so much to edit and I fear a new version of Events Manager will require this hard work again. Maybe EM team comes with a rational solution? Thanks.
I tried to edit that piece of code that replaces CONTENTS with the actual events list, but still on the russian page the CONTENTS word is not replaced:
//Now, we either replace CONTENTS or just replace the whole page //changed_core //polylang global $polylang; $translated_post_id = pll_get_post($events_page_id, 'ru'); $translated_page = get_page($translated_post_id); $translated_page_content = $translated_page->post_content; if( preg_match('/CONTENTS/', $page_content) ){ $content = str_replace('CONTENTS',$content,$page_content); } elseif ( preg_match('/CONTENTS/', $translated_page_content) ) { $content = str_replace('CONTENTS',$content,$translated_page_content); }
1. For the first one I figure out that the function we should edit is em_content from /em-events.php. More specifically, from line 32:
if ( $post->ID == $events_page_id && $events_page_id != 0 ) {
which I believe in the end fires this:
//Now, we either replace CONTENTS or just replace the whole page if( preg_match('/CONTENTS/', $page_content) ){ $content = str_replace('CONTENTS',$content,$page_content); }
if $post->ID is the ID of the events page we selected in the admin settings, we probably need to implement some of Polylang functions here.
Maybe something related to ‘pll_get_post()’ which returns the translation of the current page: pll_get_post($post->ID)…
I’m a rookie in this stuff, so please help me guys…
I mark this as resolved because it might be helpful for pro users.
Forum: Plugins
In reply to: [Polylang] Untranslated taxonomies/custom taxonomiesI’ve just noticed that if I add ?lang=ru at the end of the URL of each post or custom-post, the post is still displayed in the Romanian (default) and the rest is in Russian (even though the post in not translated). This is close to what I want if the post is not translated.
Demo:
https://bikeportal.md/results-2013-1/
https://bikeportal.md/results-2013-1/?lang=ruHowever, this doesn’t work with categories and other taxonomies + the switcher still wants to redirect me to the homepage (doesn’t add ?lang=ru in the href).
__________________________
This still has little-to-nothing to do with my main problem: the translated categories and other taxonomies are empty because I can’t assign untranslated posts to them.Demo:
https://bikeportal.md/category/results/
https://bikeportal.md/category/results-ru/
-> As you can see, the second one is a translated category of posts and it’s empty -> thus the language switcher from default language sees it and doesn’t add the correct URL to the Russian category.Any suggestions, tips, codes, idea would be very appreciated! I really don’t want to switch to that heavy WPML…
Forum: Plugins
In reply to: [Polylang] Untranslated taxonomies/custom taxonomiesPS. The code for my custom language switcher at the bottom of the page:
<?php if( class_exists('Polylang') && function_exists('pll_the_languages') ) { $pll_args = array('show_names'=>0,'show_flags'=>1,'hide_if_empty'=>0,'hide_current'=>1,'raw'=>1); $pll_otherlang_array = pll_the_languages($pll_args); $pll_otherlang_details = $pll_otherlang_array[0]; $pll_url = $pll_otherlang_details['url']; $pll_flag = $pll_otherlang_details['flag']; ?> <div class="mk-polylang-switcher"> <a href="<?php echo $pll_url ?>" class="mk-polylang-switcher-link"><?php echo $pll_flag ?></a> </div> <?php } ?>
Forum: Plugins
In reply to: [Polylang] Poylang: language independent categories (pll_get_taxonomies)I want to achieve a similar thing to that. For me it’s not only posts/categories but also custom posts/categories and events manager events/event categories. And more specifically, I want to be able to see the posts/custom posts/events regardless of the language chosen. In my case, pressing on one category redirects me to the default language.
So I thought, and even opened a topic, what if Polylang let us assign posts to its default category + its counter-language category (that is now hidden).
What do you think?
Thanks for your tips, Phil.
Unfortunately, I’m far from being able to develop a plugin of such complexity. I will try to contact the guys from Polylang to see whether they can help me out with that.
Have a nice day,
FilipPS. I am aware that I can replicate that page with the following lines:
[event_search_form] [events_list limit="10" events_search_form="1" pagination="1"]
But the problem is that the search form redirects me to the default language search form page.