首页 » WordPress » 在下拉菜单中显示分类列表

在下拉菜单中显示分类列表

September 7th, 2008 at 11:31pm 雪山飞猪

有时候,你想在下拉菜单分类列表中显示分类列表,并且不用按提交按钮就能够跳转,最简单的办法就是使用 wp_dropdown_categories 模板标签函数。下面是具体代码:

<form action="<?php bloginfo('url'); ?>/" method="get">
    <?php
        $select = wp_dropdown_categories('show_option_none=Select Category&show_count=1&orderby=name&echo=0&selected=6');
        $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
        echo $select;
    ?>
    <noscript><input type="submit" value="View" /></noscript>
</form>

翻译自:Most Desired WordPress Hacks: 11 Common Requests and Fixes 第五点。Leojn 也作了翻译。

作者:雪山飞猪
原文链接:在下拉菜单中显示分类列表

标签:

17fav 收藏本文 [Post to Twitter]分享到 Twitter

7 条评论 添加你的评论

Trackbacks/Pingbacks

发表评论

必须

必填,打死不公开

:mrgreen: :neutral: :twisted: :arrow: :shock: :smile: :???: :cool: :evil: :grin: :idea: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: :!: :?:

如何学淘宝封百度 wfans.org 插件推荐 2008-09-08


强烈推荐

PureCSS WordPress Theme 长期承接 WordPress 项目

最新日志

最新留言

赞助商