I explain my problem : I needed to do a specific search bar for a client. Instead of giving the possibility to the user to type a search I need to put a dropdown with choices, make him select what he wants and then show every posts related to his choice. I have one custom post type with two taxonomies for it. My code for the select :
$pre_form = '<form role="search" method="get" class="search-form" id="searchform" action="' . esc_url(home_url('/')) . '">
<div>';
$taxonomies = 'aeronef';
$args = array('order' => 'ASC', 'hide_empty' => true);
function get_terms_dropdown_test($taxonomies, $args)
{
$myterms = get_terms($taxonomies, $args);
$output = "<select name='s'>";
foreach ($myterms as $term) {
$term_slug = $term->slug;
$term_name = $term->name;
$link = $term_slug;
$output .= "<option name='" . $link . "' value='" . $link . "'>" . $term_name . "</option>";
}
$output .= "</select>";
return $output;
}
echo $pre_form;
echo get_terms_dropdown_test($taxonomies, $args);
echo '<input type="submit" class="search-submit" value="' . esc_attr_x('Search', 'submit button') . '" />
</div>
</form>';
The problem is : It works perfectly fine when I use the taxonomy "gamme" (it shows me all the terms, i can select it, it shows me all the posts with this term and i can go on the detail of the post) but when i try with "aeronef" it shows me no terms. But I don't have an error. I checked everything, I have terms in it, WP recognize it as a taxonomy and can find terms if I put an ID to search, but with the "get_terms" function it finds the taxonomy but shows no terms.
Thx for helping !