1

我需要在 Wordpress 中显示各种类别。用户可以选择游戏类型(竞技场、指南、蒙太奇)的类别(火术师、萨满祭司、守望者)。 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>

对不起,我的英语不好。我把一些词从德语翻译成英语。

4

1 回答 1

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>``
于 2013-09-27T03:17:34.270 回答