0

i'm working on this tutorial called "How to Create an Advanced Search Form for WordPress" (http://fearlessflyer.com/2012/10/how-to-create-an-advanced-search-form-for-wordpress/) and it works perfect. But i have a problem trying to show the Taxonomy-name instead of the Taxonomy-slug in the first 'Option' selector.

I know the problem is here, in 'functions.php' but i don't know how to rewrite it to get what i want:

function buildSelect($tax){  
$terms = get_terms($tax);
$x = '<select name="'. $tax .'">';
$x .= '<option value="">'. ucfirst($tax) .'</option>';
foreach ($terms as $term) {
    $x .= '<option value="' .$term->slug . '">' . $term->name . '</option>';
}
$x .= '<select>';
return $x;
}

I'd appreciate any help to solve this. Thank you very much.

Javi Gil
  • 1
  • 2
  • what you have seems ok to me... – danyo Jul 30 '13 at 13:27
  • Yes, the code is ok, but in the 4th line I need to display the Taxonomy-name, not the slug. Because in spanish some words have accent and the slug doesn't show these characters. – Javi Gil Jul 30 '13 at 14:02

1 Answers1

0

you could try something like this:

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo  $term->name;
danyo
  • 5,686
  • 20
  • 59
  • 119