Get Question, Answers and Comments Id from Permalink

5.64K viewsWordPress
1

I wanted to know if, there is any way to (reverse) get Question Id and Ids of its associated Answers and comments.

For e.g., Permalink of one of the questions is –

http://medicoshive.com/discussion/question/most-abundant-element-in-nature-is/

How to retrieve Question/Answers/Comments Ids from this link

I learnt about url_to_postid( $url ) function. But I hope to find a way to get more info (Because my main stress is to get Answers Id).

Why I want this – Because I need to display all available answers to a particular question on some other page (which is basically on completion of a quiz question), so if there is any other way to do this, that could be helpful.

Thanks.

0

You can get current question ID using:

get_question_id();

And you can get answer loop using:

global $answers;
$answers = ap_get_answers(array('question_id' => get_question_id() ));
include( ap_get_theme_location( 'answers.php' ) );
You are viewing 1 out of 2 answers, click here to view all answers.