In Wordpress, I added fields for Spanish Content and Spanish Title in posts. I made a filter to switch the content when Spanish is selected. (See below.) This works in the post but is writing every title in the navigation with the current page title. How could this be re-written to avoid this problem?
PHP Code:if($lan=='es'){
add_filter('the_content','spanish_content');
add_filter('the_title','spanish_title');
}
function spanish_content($content){
$spanish=get_post_meta(get_the_id(), 'spanish_content');
$span= $spanish[0];
if(!$span){
$span='<p><em>Spanish translation is not available.</em></p>'.$content;
}
return $span;
}
function spanish_title($title){
$spanish=get_post_meta(get_the_id(), 'spanish_title');
$span= $spanish[0];
if(strlen($span)<1){
return $title;
}
return $span;
}



Reply With Quote
Bookmarks