How can i remove some categories from Ask Question form?

Solved4.86K viewsGeneral
0

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
0

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

<?php
/**
 * 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
0

Hi, Samagaz
Did you solve this problem?

Answered question