Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Last Viewed Posts (LVP) plugin on a qTranslate-enabled website. LVP shows post titles in both languages. I found this hint: titles in recent posts appear together in all languages with qtranslate

But not sure how to apply this filter. Relevant code in LVP:

        foreach ($zg_post_IDs as $value) { // Do output as long there are posts
        global $wpdb;
        $zg_get_title = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE ID = '$value+0' LIMIT 1");
        foreach($zg_get_title as $zg_title_out) {
            echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title . "\">". $zg_title_out->post_title . "</a>, \n"; // Output link and title
        }

Instead of echo $post->post_title; it has $zg_title_out->post_title.

Replacing the whole zg string with apply_filters('the_title',$post->post_title) didn't work.

share|improve this question
    
With some trial and error, solved (above). Now I see that there's a semicolon after every post link. How can I omit the semicolon after the last link? –  Phantasmix Sep 12 '12 at 2:41

1 Answer 1

up vote 0 down vote accepted

Solution -

take out:
foreach($zg_get_title as $zg_title_out) { echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title . "\">". $zg_title_out->post_title . "</a>, \n"; // Output link and title

insert:

foreach($zg_get_title as $post) { echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $post->post_title . "\">". apply_filters('the_title',$post->post_title) . "</a>; \n"; // Output link and title

$zg_title_out was replaced with $post,
and $zg_title_out->post_title was replaced with $post->post_title

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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