harsh deshmukh
asked 11 years ago

Hi Team,
After deleting a question which has some recent answer, Latest Answer short code is not working properly.
We can still see Answer At option for corresponding Latest Answer(which is no more available).
https://www.dropbox.com/s/oo8eitrmdmc2id0/Latest%20Answer%20Bug.JPG


Regards,
Harsh

1 Answers
harsh deshmukh
answered 11 years ago

Hi Dominic,
Thanks a Lot.. 🙂

I added the code in shortcode.php file Its working fine. 
The code modification is as below:
 
 
if( $questions->have_posts() ) {
$html .= ‘<div class=”dwqa-latest-answers”>’;
$html .= ‘<ul>’;
while ( $questions->have_posts() ) { $questions->the_post();
$answer_id = get_the_ID();
$question_id = get_post_meta( $answer_id, ‘_question’, true );
if( ‘publish’ != get_post_status( $question_id ) ) {
continue;
}

if( $question_id ) {
$html .= ‘<li>’.__(‘Answer at’,’dwqa’).’ <a href=”‘.get_permalink( $question_id ).’#answer-‘.$answer_id.'” title=”‘.__(‘Link to’,’dwqa’).’ ‘.get_the_title( $question_id ).'”>’.get_the_title( $question_id ).'</a></li>’;
}
}
$html .= ‘</ul>’;
$html .= ‘</div>’;
}
wp_reset_query();
wp_reset_postdata();
return $html;
}
 
Regards,
Harsh

Powered by DW Question & Answer Pro