get_question_id()

Description #

Get current question ID in single question page.

Changelog #

VersionDescription
unknownunknown
4.2.0Return only integer.
4.1.0Introduced.

Source #

File: includes/functions.php

function get_question_id() {
	if ( is_question() && get_query_var( 'question_id' ) ) {
		return (int) get_query_var( 'question_id' );
	}

	if ( is_question() ) {
		return (int) get_queried_object_id();
	}

	if ( get_query_var( 'edit_q' ) ) {
		return (int) get_query_var( 'edit_q' );
	}

	if ( ap_answer_the_object() ) {
		return (int) ap_get_post_field( 'post_parent' );
	}

	return 0;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment