Get Question, Answers and Comments Id from Permalink

5.85K viewsWordPress

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 –

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.



You can get current question ID using:


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' ) );