harsh deshmukh
asked 8 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

2 Answers
BigHug
answered 8 years ago

Thank you very much for this feedback. We will fix and update this soon. you can go direct to the 414 add these code beline:

 
if( 'publish' != get_post_status( $question_id ) ) {
continue;
}

It will hep you to fix this problem

harsh deshmukh
answered 8 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