Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Chouby

    (@chouby)

    Yes I confirm. I added a notice to warn users on the page you linked to.
    I don’t have a solution to propose for now.

    Plugin Author Chouby

    (@chouby)

    I tried a completely different approach. That’s a plugin (and no more a theme hack).

    <?php
    /*
    Plugin name: Fallback to Polylang default language
    */
    
    if (defined(POLYLANG_VERSION)) {
    	add_action ('pre_get_posts', 'pll_pre_get_posts');
    	add_action ('wp', 'pll_wp');
    }
    
    function pll_pre_get_posts($query) {
    	global $polylang;
    
    	if (!$query->is_main_query())
    		return;
    
    	unset($query->query_vars['lang']);
    	$polylang->choose_lang->set_lang_query_var($query, $polylang->model->get_language($polylang->options['default_lang']));
    }
    
    function pll_wp() {
    	global $wp_query;
    
    	if (!$wp_query->is_main_query())
    		return;
    
    	foreach (wp_list_pluck($wp_query->posts, 'ID') as $id) {
    		$tr_ids[$id] = pll_get_post($id);
    	}
    
    	foreach ($posts = get_posts(array('include' => $tr_ids)) as $key => $p) {
    		$tr_posts[$p->ID] = &$posts[$key];
    	}
    
    	foreach($wp_query->posts as $key => $p) {
    		if (!empty($tr_ids[$p->ID])) {
    			$wp_query->posts[$key] = &$tr_posts[$tr_ids[$p->ID]];
    		}
    	}
    }

    Thread Starter AliBK

    (@alibk)

    Thanks for the response, Chouby. I’ve installed that script as a plugin (and removed the theme hack) but I’m not seeing any effect on the blog page. Are there any other changes I’d need to make?

    Thread Starter AliBK

    (@alibk)

    Sorry for the bump. Just wondered if you had a moment to let me know how that should be implemented? I’ve installed it as a plugin, but can’t see any effects.

    Plugin Author Chouby

    (@chouby)

    It worked for me with the settings I had when writing it. It may not work on all possible of settings combinations.

    Are you using a static front page?

    Thread Starter AliBK

    (@alibk)

    Yes, I am using a static front page, the blog appears on another ‘news’ page. Is it possible to tweak the plugin to cover a blog page like this?

    In case it helps, here’s the blog page: http://www.sonializakenterman.com/news/

    Thread Starter AliBK

    (@alibk)

    Hi Chouby, sorry to hassle, but I was wondering if you had any thoughts on how to adapt the proposed solution to a site with a static front page?

    i would like to know if / how this works when using a static front page as well.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Default/fallback language breaks pagination’ is closed to new replies.