How to filter category in ask form

Solved3.63K viewsThemescategory
0

Hi,
This is my category level.

Parent1
 - Child1
 - Child2
 Parent2
 - Child3
 - Child4


I want to only Child3 and Child4 category in ask form.
How can I do it.
Thanks.

Question is closed for new answers.
Answered question
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 );

Posted new comment

Wow, Thanks.

You are viewing 1 out of 2 answers, click here to view all answers.