管理中的Wordpress分类过滤器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了管理中的Wordpress分类过滤器相关的知识,希望对你有一定的参考价值。
add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' ); function my_restrict_manage_posts() { // only display these taxonomy filters on desired custom post_type listings global $typenow; if ($typenow == 'photos' || $typenow == 'videos') { // create an array of taxonomy slugs you want to filter by - if you want to retrieve all taxonomies, could use get_taxonomies() to build the list foreach ($filters as $tax_slug) { // retrieve the taxonomy object $tax_obj = get_taxonomy($tax_slug); $tax_name = $tax_obj->labels->name; // retrieve array of term objects per taxonomy $terms = get_terms($tax_slug); // output html for taxonomy dropdown filter echo "<select name='$tax_slug' id='$tax_slug' class='postform'>"; echo "<option value=''>Show All $tax_name</option>"; foreach ($terms as $term) { // output each select option line, check against the last $_GET to show the current option selected echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>'; } echo "</select>"; } } }
以上是关于管理中的Wordpress分类过滤器的主要内容,如果未能解决你的问题,请参考以下文章
php 这个WordPress插件演示了如何使用WordPress提供的可拖动元文件构建自己的插件页面,需要WordPr