• Resolved panos76

    (@panos76)


    Hi,
    I had the same problem in the past, but I fixed it with some addition in the code of my theme. Now, after the last upgrade of Polylang, the problem is back. Any idea how to fix it please? Here is the code:

    if ( is_home() ){
    		$args = array(
    			'showposts'=> (int) get_option('notebook_homepage_posts'),
    			'paged'=>$paged,
    			'post_type' => 'post',
    			'lang' => get_query_var('lang'),
    			'category__not_in' => (array) get_option('notebook_exlcats_recent'),
    		);
    		if ( 'false' == get_option('notebook_duplicate') ){
    			$args['post__not_in'] = $ids;
    		}
    		query_posts( apply_filters( 'notebook_homepage_args', $args ) );
    	}

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    https://www.ads-software.com/plugins/polylang/

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

    (@chouby)

    Could you tell me if it works with the current development version (1.2.3.4). I fixed a bug which may impacted you.
    https://downloads.www.ads-software.com/plugin/polylang.zip

    Thread Starter panos76

    (@panos76)

    Yes! Everything is ok now, thanks!!!

    Thread Starter panos76

    (@panos76)

    Hi,
    I updated to 1.3 and I have again the same problem!

    Plugin Author Chouby

    (@chouby)

    As performance optimization, Polylang does not set anymore the ‘lang’ query var but does set directly the tax_query. That saves 1 query (that WP does not cache !). On my own site, I saved 3 queries on home page ??

    Try this code which should be better:

    if ( is_home() ){
    		$args = array(
    			'showposts'=> (int) get_option('notebook_homepage_posts'),
    			'paged'=>$paged,
    			'post_type' => 'post',
    //			'lang' => get_query_var('lang'),
    			'category__not_in' => (array) get_option('notebook_exlcats_recent'),
    		);
    		if ( 'false' == get_option('notebook_duplicate') ){
    			$args['post__not_in'] = $ids;
    		}
    
    		$args = array_merge($GLOBALS['wp_query'], $args);
    
    		query_posts( apply_filters( 'notebook_homepage_args', $args ) );
    	}
    Thread Starter panos76

    (@panos76)

    It works, thank you!

    Hi Chouby. I just updated to PL 1.3 and the issue I have might be related to this.

    I already had this issue before, during 1.2 Beta testing

    Please check the images from the first post in this topic:

    https://www.ads-software.com/support/topic/polylang-12-beta-is-ready-for-tests/page/3?replies=82

    I remember your correction was fast.

    Thank you in advance!

    Plugin Author Chouby

    (@chouby)

    No that’s a totally different issue. Unfortunately, I can’t go back to the previous version. What works for WP-Ecommerce is in fact buggy and creates conflicts for other users with more generic needs. That’s why I modified the code again…

    So you will have to introduce a specific code for WP-Ecommerce in a custom plugin. This should work for the products page:

    <?php
    /*
    Plugin name: Polylang WP E-Commerce Compatibility
    */
    
    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);
    	}
    }

    Hi, Chouby.

    The WP e-Commerce developer community is evaluating replacing the short code approach to detect their CPT pages, in favor of using the CPT pages’ page_name slugs. That would require to fix the WPML interfacing plugin too.

    The change of behavior I described is really difficult to track for me, because I would reach the end of the parse_query filter with all the wpsc-product CPT posts in all languages selected, without knowing what didn’t happened which would select the current language posts to be shown on this CPT page only. That’s why I had to ask.

    I’ll add this to my Polylang/WP e-Commerce plugin to test later on. I’m currently hooked to the wpsc_get_the_post_id_by_shortcode filter hook, switching the CPT pages post ID using pll_get_post to send the translated post ID, so I think that I have to enter it like this:

    <?php
    /*
    Plugin name: Polylang WP E-Commerce Compatibility
    */
    
    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( wpsc_get_the_post_id_by_shortcode( '[productspage]' ) )) {
    		global $polylang;
    		$polylang->choose_lang->set_lang_query_var($query, $polylang->curlang);
    	}
    }

    Thank you, Chouby.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Both languages in homepage’ is closed to new replies.