I’ve searched and found this and a few more. But I still couldn’t get the selected name (not value as value is just a number). get_categories keeps returns an empty array.
Below is the code from the plugin that I’m modding.
$categories = apply_filters( 'acadp_admin_listing_form_categories_dropdown', '', $post->ID );
if ( empty( $categories ) ) {
$selected_category = count( $category ) ? $category[0] : -1;
$args = array(
'show_option_none' => '-- ' . esc_html__( 'Select category', 'advanced-classifieds-and-directory-pro' ) . ' --',
'taxonomy' => 'acadp_categories',
'name' => 'acadp_category',
'orderby' => 'name',
'selected' => (int) $selected_category,
'hierarchical' => true,
'depth' => 10,
'show_count' => false,
'hide_empty' => false,
'echo' => false,
);
if ( $disable_parent_categories ) {
$args['walker'] = new ACADP_Walker_CategoryDropdown;
}
$categories = wp_dropdown_categories( $args );
}
echo $categories;