我的类别有一个下拉菜单:
<form action="<?php bloginfo(\'url\'); ?>" method="get" id="catform">
<?php
$parent = get_cat_ID("Pictures");
$select = wp_dropdown_categories("child_of=".$parent."&hide_empty=0&orderby=name&echo=0&show_option_none=Select...");
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange=\'return this.form.submit()\'>", $select);
echo $select;
?>
</form>
选择选项后,会自动转到相关的类别页面。这是伟大的工作,除了一个小细节。。。默认选项。
我有一个默认选项,名为Select...
, 但我没有意识到的是,当你选择这个选项时,有些东西会被退回。在普通页面上,似乎什么都没有发生,但那是因为Select...
默认情况下选择。在类别页面上(category.php
), 如果您选择Select...
您将被重定向到:http://myurl.com/?cat=-1.
如果有人选择Select...
页面未提交表单?
谢谢你,乔希