0

I am using a WordPress 3.8 installation with qtranslate, and everything is working except for the recent posts titles. Qtranslate displays the titles with all languages after each other. Like: English title German title French title

The code I am using to display a list with recent post titles is:

<?php
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
    echo '<li class="lastposts"><a href="' . get_permalink($recent["ID"]) . '" title="'.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
}
?>

I have googled for this problem and it seems like Qtranslate does not work with post_title. How can I make it work?

0

1 Answer 1

0

Qtranslate works probably with a filter on the_title. So you have to use functions that make use of that filter, not the raw post title.

Example, not tested:

foreach( $recent_posts as $recent ) {
    printf(
        '<li class="lastposts"><a href="%1$s" title="%2$s" >%3$s</a></li>',
        get_permalink( $recent["ID"] ),
        the_title_attribute(
            array (
                'post' => $recent["ID"],
                'echo' => FALSE
            )
        ),
        get_the_title( $recent["ID"] )
    );
}
1
  • Thank you very much! It tested it and it works perfectly. Really appreciate your help. thanks again, i have been messing with this for hours. :)
    – Tanks
    Commented Jan 15, 2014 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.