我正在编写这篇名为“如何为WordPress创建高级搜索表单”(http://fearlessflyer.com/2012/10/how-to-create-an-advanced-search-form-for-wordpress/)的教程,它运行得非常完美。但我在第一个“选项”选择器中显示Taxonomy-name而不是Taxonomy-slug时遇到了问题。
我知道问题在这里,在'functions.php‘中,但我不知道如何重写它来获得我想要的:
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;
}如果能帮我解决这个问题,我将不胜感激。非常感谢。
发布于 2013-07-30 22:11:39
您可以尝试如下所示:
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name;https://stackoverflow.com/questions/17946256
复制相似问题