Hi,
if i understand correctly you would like to have two different [adverts_add] forms and the forms would have different categories.
There are two ways to do that:
1. the easiest (that is not requiring any programming knowledge, but might require quite a lot of manual work if you have a lot of categories), would be to edit a category field in each form.
In “Fill Method” select “I will enter options myself” and check the “use values” checkbox.
Finally, manually fill the available categories for this form, the options values need to be equal to category IDs the option labels can be the same or similar as the category titles.
When you save the form, it should have only the predefined list of options / categories when posting an Ad in the frontend.
2. the second method would require creating two data sources as explained here https://wpadverts.com/documentation/custom-fields-paid-addon/, each data source function would need to somehow filter which categories are assigned to this data source.
add_action( "init", function() {
wpadverts_custom_fields_register_data_source(array(
"name" => "adverts-categories",
"title" => __( "Adverts Categories (Trade)", "wpadverts-custom-fields" ),
"callback" => "adverts_taxonomies_trade"
));
wpadverts_custom_fields_register_data_source(array(
"name" => "adverts-categories",
"title" => __( "Adverts Categories (Business)", "wpadverts-custom-fields" ),
"callback" => "adverts_taxonomies_business"
));
} );
function adverts_taxonomies_trade( $taxonomy = 'advert_category' ) {
$args = array(
'taxonomy' => $taxonomy,
'hierarchical' => true,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'depth' => 0,
'selected' => 0,
'show_count' => 0,
);
include_once ADVERTS_PATH . '/includes/class-walker-category-options.php';
$walker = new Adverts_Walker_Category_Options;
$params = array(
get_terms( $taxonomy, $args ),
0,
$args
);
return call_user_func_array(array( &$walker, 'walk' ), $params );
}
function adverts_taxonomies_business( $taxonomy = 'advert_category' ) {
$args = array(
'taxonomy' => $taxonomy,
'hierarchical' => true,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'depth' => 0,
'selected' => 0,
'show_count' => 0,
);
include_once ADVERTS_PATH . '/includes/class-walker-category-options.php';
$walker = new Adverts_Walker_Category_Options;
$params = array(
get_terms( $taxonomy, $args ),
0,
$args
);
return call_user_func_array(array( &$walker, 'walk' ), $params );
}
The code you can paste in your theme functions.php, note that by default both taxonomies list all of the Adverts Categories you would need to somehow customize the $args
variable in adverts_taxonomies_business() and adverts_taxonomies_trad() functions so they return only categories which should be available in a trade or business form.
One way to do that would be to add a custom field in wp-admin / Classifieds / Categories panel when editing a category and mark each category “trade” or “business”.
How to add a field to custom taxonomy you would need to read in some online tutorial, for example https://www.ibenic.com/custom-fields-wordpress-taxonomies/