Choose category automatically

1.87K viewsGeneral
0

Hi, I added this code to the theme’s function.php but not of any use. Can you help with choosing category automatically

<?php

/**

* Filter ask button link to append category id in single category.

*

* @param string $link Ask page link.

* @return string

*/

function my_ap_ask_btn_link( $link ) {

if( ap_current_page( ‘category’ ) ) {

$question_category = get_queried_object();

$link = add_query_arg( [ ‘question_form’ => [ ‘category’ => $question_category->term_id ] ], $link );

}

return $link;

}

add_filter( ‘ap_ask_btn_link’, ‘my_ap_ask_btn_link’ );

Asked question