最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - How to add Tags Filter in wordpress admin dashboard

programmeradmin4浏览0评论

How to add filter by Tags in wp admin dashboard?

There are option for category and date filter but not tags filter. I want to filter wp post by tags.

Did from many forum but didn't work.

I am non-coder. pls suggest.

How to add filter by Tags in wp admin dashboard?

There are option for category and date filter but not tags filter. I want to filter wp post by tags.

Did from many forum but didn't work.

I am non-coder. pls suggest.

Share Improve this question asked Dec 29, 2017 at 4:02 SanjeevSanjeev 313 bronze badges 1
  • Good answer below. Also, you can click the name of the tags/categories that are displayed near the post's title / other info on the 'All Posts' page (/wp-admin/edit.php) or, simply type the tag into the url: /wp-admin/edit.php?tag=test – admcfajn Commented Dec 29, 2017 at 21:27
Add a comment  | 

1 Answer 1

Reset to default 1

Done Successfully from this coding. Inserted wp-includes/function.php

function kc_add_taxonomy_filters() {
global $typenow;

// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
$my_taxonomies = array(  'post_tag' );
switch($typenow){

    case 'post':

        foreach ($my_taxonomies as $tax_slug) {


                    $tax_obj = get_taxonomy($tax_slug);
                    $tax_name = $tax_obj->labels->name;
                    $terms = get_terms($tax_slug);
                    if(count($terms) > 0) {
                        echo "<select name='$tax_slug' id='$tax_slug' class='postform alignleft actions'>";
                        echo "<option value=''>Show All $tax_name</option>";
                        foreach ($terms as $term) {
                            echo '<option value="', $term->slug,'" ',selected( @$_GET[$tax_slug] == $term->slug , $current = true, $echo = false ) , '>' , $term->name ,' (' , $term->count ,')</option>';
                        }
                        echo "</select>";
                    }

        }


    break;
}
}

Now,Insert child theme folder/function.php

add_action( 'restrict_manage_posts', 'kc_add_taxonomy_filters' );

Thanks.

发布评论

评论列表(0)

  1. 暂无评论