Home shows both language

Having Problems? Need Help? Post here!

Home shows both language

Postby motorzombi » Tue Apr 17, 2012 9:32 pm

Hi,

When I use the plugin and put the post I made in two language it shows on the home with both language, not just english or spanish eventough I change the language on the browser, it just shows both language always, here it's the code i'm using to show the custom posts on the index.php (i'm using advanced custom fields plugin)

Code: Select all
<?php
   $post_id = 48;
   $post_data = get_post($post_id, ARRAY_A);
   echo ' '.$post_data['post_title'].' ';
   echo ' '.$post_data['post_content'].'';
?>


both the content and title shows the two languages, what it's wrong?

I'm using the post_id to call the post directly from the advanced custom field plugin

thank you
motorzombi
 
Posts: 1
Joined: Tue Apr 17, 2012 9:27 pm

Re: Home shows both language

Postby tmuikku » Sat May 05, 2012 10:17 am

You are now displaying the raw content directly from the database by echoing $post_data['post_title'] and content respectively.

You should employ the default filters for displaying post title and content (see your theme template files, they use the the_title() and the_content() functions which will go trough the filters and are thus translated properly.

Here you go:

Code: Select all
<?php
   $post_id = 48;
   $post_data = get_post($post_id, ARRAY_A);
   echo ' '.apply_filters('the_title', $post_data['post_title']).' ';
   echo ' '.apply_filters('the_content', $post_data['post_content']).'';
?>


Using the filters will get other possible shortcodes done as well etc.
tmuikku
 
Posts: 9
Joined: Thu May 20, 2010 4:42 pm

Re: Home shows both language

Postby Sxiperio » Thu May 31, 2012 7:50 am

I have same problem, i trying to make special widget popular.php like page, but after instaling qTranslate my file showing all content in all languages here is my source:
Code: Select all
<?php
if (empty($pop_posts) || $pop_posts < 1) $pop_posts = 5;
$popularposts = "SELECT ID,post_title FROM {$wpdb->prefix}posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY comment_count DESC LIMIT 0,".$pop_posts;
$posts = $wpdb->get_results($popularposts);
if($posts){
   foreach($posts as $post){
      $post_title = stripslashes($post->post_title);
      $guid = get_permalink($post->ID);
      $popular .= '<li><a href="'.$guid.'" title="'.$post_title.'">'.$post_title.'</a></li>';
      }
}echo $popular;

?>

Where i must apply filters?
Sxiperio
 
Posts: 1
Joined: Wed May 30, 2012 9:19 am


Return to qTranslate Support Forum

Who is online

Users browsing this forum: Google [Bot] and 10 guests