Hi, hmm the easiest way to do that would be to just add the “Search By Category” snippet to the [adverts_list] form https://github.com/simpliko/wpadverts-snippets/blob/master/search-by-category/search-by-category.php
If you would like to display the list of categories in a similar fashion as on the page https://allubu.com/clasificados-categorias/ then this will require some custom programming.
Below you can find a code to get you started, it will check if the user is currently in the Advert Category (if he is then you need code to get sub categories for $current_category and for displaying them.
add_action( "adverts_sh_list_before", "my_categories" );
function my_categories( $args ) {
global $wp_query;
if( is_tax( 'advert_category' ) ) {
$current_category = $wp_query->get_queried_object_id();
// code for getting the sub categories and displaying them here
}
}
ok thanks, how can I get the code to display sub categories?
and Do you have an option or addon to display a badge on feautured ads?
The whole code that will do this can look like this
add_action( "adverts_sh_list_before", "categories_above_adverts_list" );
function categories_above_adverts_list( $args ) {
global $wp_query;
if( is_tax( 'advert_category' ) ) {
$current_category = $wp_query->get_queried_object_id();
// code for getting the sub categories and displaying them here
$columns = "adverts-flexbox-columns-4";
$show_count = 1;
$terms = get_terms( 'advert_category', array(
'hide_empty' => 0,
'parent' => $current_category ,
'number' => -1
) );
include ADVERTS_PATH . '/templates/categories-top.php';
}
}
Ok i installed this code but now is working at half.. I mean, when I enter a category it just dispolay one sub categorie icon.. but others are missing.. please check this: https://allubu.com/advert-category/bienes-raices/
Can you tell me what to do?
thanks for your help..
Please try changing the line 'number' => -1
to 'number' => 0
.