WordPress:Template Tags/dropdown cats
Description
This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists.
Description
描述
Displays a list of categories in a select (i.e dropdown) box.
在一个选择框(如下拉列表)上显示类别的一个列表。
Replace With
取代
Usage
用法
%%% <?php dropdown_cats(optionall, 'all', 'sort_column','sort_order', optiondates, optioncount,
hide_empty, optionnone, selected, hide); ?> %%%
%%% <?php dropdown_cats(optionall, '所有的', 'sort_column','sort_order', optiondates, optioncount,
hide_empty, optionnone, selected, hide); ?> %%%
Examples
例子
Dropdown with Submit Button
拥有提交按钮的下拉列表
Displays category select (dropdown) list in HTML form with a submit button, in a WordPress sidebar unordered list.
在WordPress工具条一个无序的列表上,显示带有一个提交按钮,以HTML形式的类别选择(下拉)列表。
<li id="categories"><?php _e('Categories:'); ?> <ul><li> <form action="<?php echo $PHP_SELF ?>" method="get"> <?php dropdown_cats(); ?> <input type="submit" name="submit" value="view" /> </form> </li></ul> </li>
<li id="categories"><?php _e('Categories:'); ?>
<ul><li> <form action="<?php echo $PHP_SELF ?>" method="get"> <?php dropdown_cats(); ?> <input type="submit" name="submit" value="view" /> </form> </li></ul> </li>
Dropdown without Submit Button
没有提交按钮的下拉列表
Displays category select (dropdown) in HTML form without a submit button.
以HTML形式显示类别选择(下拉列表),没有提交按钮。
- Download and install the plugin Drop Down Categories found here.
- 下载并且安装插件下拉列表类别在这儿可以找到。
- Add the following code to your header.php template file:
- 将下面的代码添加到你的header.php模板文件:
<script type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script>
<script type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script>
- Then add the following code to wherever you'd like the dropdown categories to be displayed (for example, your sidebar.php file):
:*然后将下面的代码添加到你希望下拉列表显示的位置(例如你的sidebar.php文件):
<form action=""> <select name="menu" onchange="MM_jumpMenu('parent',this,0)"> <option>Choose one</option> <?php dropdown_cats_exclude('name', 'asc'); ?> </select> </form>
<form action=""> <select name="menu" onchange="MM_jumpMenu('parent',this,0)"> <option>Choose one</option> <?php dropdown_cats_exclude('name', 'asc'); ?> </select> </form>
Parameters
参数
- optionall
- (boolean) Sets whether to have an option to display all categories. Valid values:
;optionall : (boolean)设置是否显示所有的类别。有效的参数值:
- TRUE (Default)
- 正确的 (默认的)
- FALSE
- 错误的
- all
- (string) Text to display for the option to display all categories. Defaults to 'All'.
- 所有的
- (string)命令选项显示所有类别的文本。默认'所有的'。
- sort_column
- (string) Key to sort options by. Valid values:
- sort_column
- (string)选项分类的关键词。有效的参数值:
- 'ID' (Default)
- 'ID'(默认的)
- 'name'
- '名称'
- sort_order
- (string) Sort order for options. Valid values:
- 分类_顺序
- (string)选项的分类顺序。有效的参数值:
- 'asc' (Default)
- 'asc' (默认的)
- 'desc'
- 'desc'
- optiondates
- (boolean) Sets whether to display the date of the last post in each category. Valid values:
- optiondates
- (boolean)设置是否显示每篇文章中最后一篇文章的发表日期。有效的参数值:
- TRUE
- 正确的
- FALSE (Default)
- 错误的 (默认的)
- optioncount
- (boolean) Sets whether to display a count of posts in each category. Valid values:
- optioncount
- (boolean)设置是否显示每个类别中文章的数目。有效的参数值:
- TRUE
- 正确的
- FALSE (Default)
- 错误的 (默认的)
- hide_empty
- (boolean) Sets whether to hide (not display) categories with no posts. Valid values:
- 隐藏_空的
- (boolean)设置是否隐藏(不显示)没有文章的类被。有效的参数值:
- TRUE (Default)
- 正确的 (默认的)
- FALSE
- 错误的
- optionnone
- (boolean) Sets whether to have an option to display none of the categories. Valid values:
- optionnone
- (boolean)是否设置一个选项,不显示任何类别。有效的参数值:
- TRUE
- 正确的
- FALSE (Default)
- 错误的 (默认的)
- selected
- (integer) Sets the default selected category ID number. Defaults to current category.
- 挑选的
- (整数)设置挑选的类被ID数字。默认为当前的类别。
- hide
- (integer) Do not display this category (specified by category ID number). There is no default.
- 隐藏
- (整数)不显示这个类别(由类别ID数字规定)。没有默认值。
Fixes
解决办法
When you choose a category when you are not on the main page, you will not move to that category. To fix this find the following line in the template where you are using Dropdown cats.
当你不在主页上时,选择了一个类别,你就不会转到那个类别。要解决这个问题,在你使用下拉列表cats的模板中,找到下面的命令行。
<form action="<?php echo $PHP_SELF ?>" method="get"> Replace it with : <form action="<?bloginfo('url');?>/index.php" method="get">
<form action="<?php echo $PHP_SELF ?>" method="get"> 替换为 : <form action="<?bloginfo('url');?>/index.php" method="get">
This is a temporary fix to the problem, a real fix will probably come soon. This problem is usually only found on blogs using Apache Rewrite rules.
这是暂时解决问题的办法,真正解决问题的方法不久可能就会产生。这个问题通常会出现在使用Apache Rewrite 规则的博客上。
(Added by Chenu J, minor edit by Derek Scruggs)
(由 Chenu J添加, 由 Derek Scruggs简单地编辑了)
Related
the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_the_category get_category_link,
相关的
the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_the_category get_category_link