Skip to content

Instantly share code, notes, and snippets.

@rahularyan
Created February 11, 2018 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahularyan/abb7df3b44e21fe0c9624fc8dbec457a to your computer and use it in GitHub Desktop.
Save rahularyan/abb7df3b44e21fe0c9624fc8dbec457a to your computer and use it in GitHub Desktop.
Display single question category of AnsPress
<?php
$category_id = 1; // Replace it.
$question_args = array(
'tax_query' => array(
array(
'taxonomy' => 'question_category',
'field' => 'id',
'terms' => array( $category_id ),
),
),
);
$question_category = get_term( $category_id, 'question_category' );
if ( $question_category ) {
anspress()->questions = ap_get_questions( $question_args );
/**
* This action can be used to show custom message before category page.
*
* @param object $question_category Current question category.
* @since 1.4.2
*/
do_action( 'ap_before_category_page', $question_category );
include( ap_get_theme_location( 'addons/category/single-category.php' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment