How can i remove some categories from Ask Question form?

Solved784 viewsGeneral

How can i remove for example category named “unlimited-staff” from ask question form page?
I removed it using jquery, but will be great to do it from the code, or just have some checkbox in the category page to select categories that dont want to people ask questions!

Question is closed for new answers.
Selected answer as best

Here I have created a sample code for you. You can pass custom arguments for terms query through terms_args

 * Override AnsPress form category field selection list.
 * @param mixed $form 
 * @return mixed 
function anspress_override_category_field( $form ){
    $form['fields']['category'] = array(
        'label'    => __( 'Category', 'anspress-question-answer' ),
        'desc'     => __( 'Select a topic that best fits your question.', 'anspress-question-answer' ),
        'type'     => 'select',
        'options'  => 'terms',
        'order'    => 2,
        'validate' => 'required,not_zero',
        'terms_args' => array(
     return $form;
add_action( 'ap_question_form_fields', 'anspress_override_category_field', 99999 );

Selected answer as best
You are viewing 1 out of 3 answers, click here to view all answers.