fokus3
Forum Replies Created
-
Forum: Plugins
In reply to: [Polylang] Show default language if no translation is availablethis seems to be the only solution that works a bit. Bt this will break pagination (404 on page > 1).
Is there really no working solution without changing the loop? In WPML this works like a charme… and I guess it should be also possible in PL in a smart way…?
global $wp_query; $categories = get_the_category(); $category_id = $categories[0]->cat_ID; $deCatId = pll_get_term($category_id, 'de'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array_merge($wp_query->query, array( 'post_type' => 'post', 'paged' => $paged, 'lang' => 'de', 'cat'=> $deCatId, 'category_name' => null, 'suppress_filters' => true ))); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post() ?> <? if (function_exists('pll_current_language')) if($post_id = pll_get_post(get_the_ID(), pll_current_language())) { $post = get_post($post_id); setup_postdata($post); } ?> ...Forum: Plugins
In reply to: [Polylang] NOT change the language depending on the contentI have the same problem and have tested the approach. But it doesn’t work for me.
Forum: Plugins
In reply to: [Polylang] Show default language if no translation is availableno way, unfortunaly this function doesn’t work. nothing happens 🙁 do you have any other idea?
Forum: Plugins
In reply to: [Polylang] Show default language if no translation is availableHi there,
is it possible that this suggested piece of code does not working anymore in WP 4.2.4? Is there another solution for mixed multi-lang content available?
add_filter( 'pre_get_posts', 'get_default_language_posts' );
function get_default_language_posts( $query ) {
if ( $query->is_main_query() && function_exists('pll_default_language')){
$terms = get_terms('post_translations'); //polylang stores translated post IDs in a serialized array in the description field of this custom taxonomy
$defLang = pll_default_language(); //default lanuage of the blog
$curLang = pll_current_language(); //current selected language requested on the broswer
$filterPostIDs = array();
foreach($terms as $translation){
$transPost = unserialize($translation->description);
//if the current language is not the default, lets pick up the default language post
if($defLang!=$curLang) $filterPostIDs[]=$transPost[$defLang];
}
if($defLang!=$curLang){
$query->set('lang' , $defLang.','.$curLang); //select both default and current language post
$query->set('post__not_in',$filterPostIDs); // remove the duplicate post in the default language
}
}return $query;
}Forum: Plugins
In reply to: [Polylang] Bug? Menu disappears on "paged" and category pageswell, I made some further checks and have deactivated Polylang. Everything works fine w/o Polylang. But when I activate PL again, the menu disappears on paged pages 🙁
any idea, please?
Forum: Plugins
In reply to: [Polylang] Show default language if no translation is availableHi Chrystl,
yes I did. The first code examples on this thread do not work and the code below in the post with the “continue” statement in the loop was working (after some modification), but is breaks the loop.
Breaking the loop means, that I will show 5 posts on a page and when the “continue” condition is sometimes true then less then 5 posts are shown (obviously).
In other words: the solution itself is working but is not really usefull and the problem still exist.
Forum: Plugins
In reply to: [Polylang] Redirection with custom rules failsI get the Fatal Error when I try to activate both plugins at the same time 🙁
Forum: Plugins
In reply to: [Polylang] Redirection with custom rules failsI will test the new version and hope that it will solve my 404-problem 🙂 However with this beta occurred an error with redeclaration of icl_get_home_url
PHP Fatal error: Cannot redeclare icl_get_home_url() (previously declared in /Volumes/Daten/Websites/SpeedSkatingNews.info/wp-content/plugins/polylang/include/wpml-compat.php:44) in /Volumes/Daten/Websites/SpeedSkatingNews.info/wp-content/plugins/sitepress-multilingual-cms/inc/template-functions.php on line 27It necessary to have both plugins activated so that the WPML-Importer can work….
Forum: Plugins
In reply to: [Polylang] Redirection with custom rules failsI already made the work with this beta (I guess 🙂 Well, I will check this in the next days and it seems so, that it was redirected by this function and so my custom query_vars gone lost. Currently, I don’t understand the system behind, but I will investigate here further…
Forum: Plugins
In reply to: [Polylang] Redirection with custom rules failsI guess I’ve found a work-around. It seems to have anything to do with the
check_canonical_urlfunction. Now I used the undocumented filter (see below):add_filter('pll_check_canonical_url','canonical_url'); function canonical_url($redirect_url) { return false; }It is nice that it works, however I don’t understand, why my rule isn’t fired in the first step.
Forum: Plugins
In reply to: [Polylang] Redirection with custom rules failsHi,
well it is pretty simple. I send you here the full code so that you can reproduce the problem
add_filter('query_vars', 'myvar_vars'); function myvar_vars($public_query_vars) { $public_query_vars[] = 'skater'; return $public_query_vars; } add_action('generate_rewrite_rules', 'myvar_add_rewrite_rules'); function myvar_add_rewrite_rules($wp_rewrite) { $new_rules = array( '(de|en)/data/skater/(.*?)?/?$' => 'index.php?page_id=814&skater='.$wp_rewrite->preg_index(2).'&lang='.$wp_rewrite->preg_index(1), '(data/skater)/(.*?)?/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(1).'&skater='.$wp_rewrite->preg_index(2), '(de|en)/(data/skater)/(.*?)?/?$' => 'index.php?pagename='.$wp_rewrite->preg_index(2).'&skater='.$wp_rewrite->preg_index(3).'&lang='.$wp_rewrite->preg_index(1), ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action( 'template_redirect', 'change_search_url_rewrite' ); function change_search_url_rewrite() { global $wp_query, $wp, $db; error_log(print_r($wp,true)); }Well, this is the code, I’m using to test. The “only” problem is, that when I activate Polylang, my rules are not fire (but they are firing with WPML or rule analyzer etc.).
For me it seems so, that when activating PL it does anything with the rewrite rules, so that they are not working anymore. In fact “skater” is not set, because the wrong rule is taken. One of the real strange things is, that the rule analyzer is working as expected in the WP-Admin.
Du you have an idea? It is really important to me, because PL seems to be must more performant then WPML and I really would like to switch. But therefore it has to work before 😉
regards,
LarsForum: Plugins
In reply to: [Polylang] Redirection with custom rules failsHi,
I made some further tests to try to find a solution, but I havent’t. But perhaps this can help you to give me a piece of support.
At first I swiched back to WPML (backup) and made a call to
http://ssn.localhost/de/data/skater/nico-ihle/The output from by error_log in template_redirect (see my last post) was:
[query_vars] => Array ( [page_id] => 814 [skater] => nico-ihle ) [query_string] => page_id=814&skater=nico-ihle [request] => de/data/skater/nico-ihle [matched_rule] => de/data/skater/(.+) [matched_query] => page_id=814&skater=nico-ihle [did_permalink] => 1I was forwarded to the correct page. Fine!
Now I turned off WPML and turned on PL and imported all posts (WPML to PL Importer)
I called now the same link and get/got:
[query_vars] => Array ( [page] => [pagename] => data/skater [lang] => de ) [query_string] => pagename=data%2Fskater&lang=de [request] => de/data/skater [matched_rule] => (en|de)/(.?.+?)(/[0-9]+)?/?$ [matched_query] => lang=de&pagename=data%2Fskater&page= [did_permalink] => 1it redirects me to
http://ssn.localhost/de/data/skater/.As you can see, there is no more
skaterparameter inquery_vars. My custom rule isn’t been used.Next I checked my rewrite rules using the Rewrite analyzer plugin. There I entered
de/data/skater/nico-ihle. The plugin shows me, that my custom rule is beeing selected:(de|en)/data/skater/(.*?)?/?$ page_id: 814 skater: nico-ihle lang: deIn other words, WPML and Rewrite analyzer are working as expected, but PL not. I hope that the given information can help you to give me a support or to identify the problem behind.
Please can you check this and provide a fix or sollution?
Thank you and regards,
LarsForum: Plugins
In reply to: [Polylang] Redirection with custom rules failsHi,
unfortunately, that isn’t the reason. I tried both: english and german. Always the same. I get redirected to the page_id 814, but this “skater” argument is not getting passed.
I far as I could see ist that the “rewrite analyzer” plugin shows me that me rule ist correct and a query_var “skater” ist set correct. Then I created a test function:
add_action( 'template_redirect', 'change_search_url_rewrite' ); function change_search_url_rewrite() { global $wp, $db; error_log(print_r($wp,true)); }simple to see the paramters. Now the pagename is correct, but “skater” is always empty. This only happens when PL is activated.
Before I used WPML and it worked like a charme.
So what can it be….?
–
LarsI have to make a clarification to my last post:
the real problem is that in my theme I had the opportunity to select a photo. When I clicked there a layer was opened and have shown my the media library, an upload AND the list of nextgen galleries with the contained images. here I was able to select an image. THIS function is lost now 🙁
Does anybody have an idea?