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.