我需要在Wordpress中显示各种类别。用户可以选择游戏类型(竞技场,指南,蒙太奇)的类(Pyromancer,Shaman,Warden)。 www.Forge-Movies.com正是我所说的。使用以下代码时,类别未显示。但“类别”位于下拉列表的标题中(show_option_none = Categories)。显然查询时出了什么问题。
<form action="<?php bloginfo('url'); ?>/" method="get"><div>
<?php
if (in_category('montages'))
{
$cat_id = get_cat_id('montages');
$select = wp_dropdown_categories('show_option_none=Categories&echo=0&hierarchical=1&parent='. $cat_id);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
}
elseif (in_category('guides'))
{
$cat_id = get_cat_id('guides');
$select = wp_dropdown_categories('show_option_none=Categories&echo=0&hierarchical=1&parent='. $cat_id);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
}
?>
<noscript><div><input type="submit" value="View" /></div></noscript></div></form>
很有趣,但执行了以下代码。
<form action="<?php bloginfo('url'); ?>/" method="get"><div>
<?php
$cat_id1 = get_cat_id('guides');
$select = wp_dropdown_categories('show_option_none=Categories&echo=0&hierarchical=1&parent='. $cat_id1);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript></div></form>
抱歉我的英语不好。我翻译了一些从德语到英语的单词。
答案 0 :(得分:0)
好的,我解决了我的问题。这对我有用:
<form action="<?php bloginfo('url'); ?>/" method="get" style="display:inline-block;">div>
<?php
if (is_category(array('7', '53', '58', '59', '60', '61', '62', '63')) )
{
//Montages
$cat_id1 = get_cat_id('montages');
$select = wp_dropdown_categories('show_option_none=Classes&echo=0&hierarchical=1&parent='. $cat_id1);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
}
elseif (is_category(array('6', '64', '65', '66', '67', '68', '69', '70')) )
{
//Arena
$cat_id1 = get_cat_id('Arena');
$select = wp_dropdown_categories('show_option_none=Classes&echo=0&hierarchical=1&parent='. $cat_id1);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
}
elseif (is_category(array('8', '71', '72', '73', '74', '75', '76', '77')) )
{
//Guides
$cat_id1 = get_cat_id('Guides');
$select = wp_dropdown_categories('show_option_none=Classes&echo=0&hierarchical=1&parent='. $cat_id1);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
}
?>
<noscript><div><input type="submit" value="View" /></div></noscript></div></form>``