Get the best or selected answer id from question id

Solved4.45K viewsGeneral
0

Hi ,

Is there any way to get the best or selected answer id from the question id ?

Thanks

1

Try this

$meta = get_post_meta($question_id, ANSPRESS_SELECTED_META, true);
if(!$meta){
   //No answer selected
}else{
   //$meta will return $answer_id
}

Hi Rahul,

Thank you so much .. It works perfectly .. Need another small help .

Any function to get the answer content from the answer_id .. actually I want to get the answer_content

You know, answer and question are WP cpts so you can use WP function, i.e. get_post_field(‘post_content’, $answer_id);

Thanks a lot Rahul …. 🙂