
I have found a way to bodge this using CSS. It’s not pretty and it does mean looping through all the translations so if anyone knows a better way I’d be very happy to hear it. Here’s what I’m doing:
function tsltContent() {
if(!isset($_GET['tr']) || empty($_GET['tr'])) {
$finalStr = "<h2>" . get_the_title() . "</h2>";
$getallcontent = apply_filters('the_content', get_the_content());
$finalStr .= $getallcontent;
}else{
$trlang = $_GET['tr'];
$finalStr;
if(have_rows('page_translations') ):
while(have_rows('page_translations')): the_row();
$newlang = get_sub_field('choose_language');
if($trlang == $newlang) {
$markup = '<div class="show-lang">';
}else{
$markup = '<div class="hide-lang">';
}
if(have_rows('translation_elements')):
while(have_rows('translation_elements')): the_row();
$trStrTitle = get_sub_field('translated_title');
$trStrContent = get_sub_field('translated_content');
$finalStr .= $markup . "<h2>" . $trStrTitle . "</h2>" . $trStrContent . "</div>";
endwhile;
endif;
endwhile;
endif;
}
return $finalStr;
}
A facepalm moment. Of course.
Thank you John, worked perfectly.
Out of curiosity, is there a way to call in a field server-side to an Admin screen?