Hallo,
ich weiß nicht, ob ich in diesem Forumsbereich richtig bin?!
Folgendes Problem:
Ich habe Dropdowns (gefüllt mit verschiedenen custom taxonomies), wenn diese ausgewählt werden, wird aber nicht das/der/die slugs zurückgegeben, sondern die ID.
Was ist falsch bzw. was muss ich dazu ändern??
Hier meine Funktion dazu:
PHP
function my_dropdown($name, $taxonomy = 'category')
{
$defaults = array(
'taxonomy' => $taxonomy,
'id' => $name,
'name' => $name,
'show_option_none' => ' - Select - ',
'selected' => get_query_var($name)
);
wp_dropdown_categories($defaults);
}
add_action('pre_get_posts', 'my_customsearch');
function my_customsearch()
{
global $wp_query;
if ( $wp_query->query_vars['post_type'] != 'schedahotel' ||
!$wp_query->is_post_type_archive ) {
return false;
}
$tax_query = array();
$topic = get_query_var('topic');
$title = get_query_var('title');
// first dropdown
if (!empty($topic) && $topic > 0) {
$tax_query[] = array(
'taxonomy' => 'topic',
'field' => 'slug',
'terms' => $topic
);
}
// second dropdown
if (!empty($title) && $title > 0) {
$tax_query[] = array(
'taxonomy' => 'title',
'field' => 'slug',
'terms' => $title
);
}
if ( sizeof($tax_query) > 0 ) {
$tax_query['relation'] = 'AND';
$wp_query->query_vars['tax_query'] = $tax_query;
}
return false;
}
// }}}
// {{{
// add my custom query vars
add_filter('query_vars', 'mycustom_query_vars');
function mycustom_query_vars($query_vars)
{
$query_vars[] = 'topic';
$query_vars[] = 'title';
return $query_vars;
}
Alles anzeigen
Danke Euch im Voraus schon mal!