• Hi,

    I am using Polylang for my website (www.bastohotel.com) and it was working prefectly fine till last week. When I am on the homepag and click to swith to another language, the homepage content itself does not change, although the navigation does.

    I tried editing the settings and double checked the text trandlations in the Polylang plugin, but nothing changed or stood out. Anybody an idea what is causing this problem? Throughout the website there is no issue at all with the page translations, only the homepage.

    Many thanks in advance!

    Veronica

Viewing 1 replies (of 1 total)
  • I was able to get this done in my TwentySixteen child theme by updating:

    template-tags.php

    Basically, the function is firing and not pulling the translated post:

    /**
     * Display a front page section.
     *
     * @param $partial WP_Customize_Partial Partial associated with a selective refresh request.
     * @param $id integer Front page section to display.
     */
    function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
    	if ( is_a( $partial, 'WP_Customize_Partial' ) ) {
    		// Find out the id and set it up during a selective refresh.
    		global $twentyseventeencounter;
    		$id = str_replace( 'panel_', '', $partial->id );
    		$twentyseventeencounter = $id;
    	}
    
    	global $post; // Modify the global post object before setting up post data.
    	if ( get_theme_mod( 'panel_' . $id ) ) {
    		global $post;
    
    		$post = pll_get_post( get_theme_mod( 'panel_' . $id ), get_bloginfo('language'));
    
    		if (!$post) {
    			$post = get_post( get_theme_mod( 'panel_' . $id ) );
    		}
    
    		setup_postdata( $post );
    		set_query_var( 'panel', $id );
    
    		get_template_part( 'template-parts/page/content', 'front-page-panels' );
    
    		wp_reset_postdata();
    	} elseif ( is_customize_preview() ) {
    		// The output placeholder anchor.
    		echo '<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel' . $id . '" id="panel' . $id . '"><span class="twentyseventeen-panel-title">' . sprintf( __( 'Front Page Section %1$s Placeholder', 'twentyseventeen' ), $id ) . '</span></article>';
    	}
    }

    Notice the use of $post = pll_get_post( get_theme_mod( ‘panel_’ . $id ), get_bloginfo(‘language’));

    If it does not have a translation it will return false. So I am displaying the default translation if it doesn’t have one.

    Notice the if (!$page) statement.

    -Jesse

    • This reply was modified 7 years, 6 months ago by webdobe.
Viewing 1 replies (of 1 total)
  • The topic ‘Homepage content not changing’ is closed to new replies.