LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress Snippets » How To Pick Most Used Categories In WordPress Without A Plugin?

How To Pick Most Used Categories In WordPress Without A Plugin?

Pick-Most-Used-Categories-In-WordPress-Without-A-Plugin
WordPress is a full features CMS platform and due to based upon PHP, its more functionable. As you know that there are many plugins available for every use of WordPress but plugins can create a very harsh result to your WordPress blog and also can compromise your security so you have to use less plugins and only top developers plugin to keep your blog safe.

So now we have a little WordPress snippet that will pick your most fills categories that have maximum posts in it and make a list of them. You can also limit that how many categories you want to pick and show. Its very easy and good for template designed and a good sidebar widget that will be also valuable and will keep your space clear of new categories that have min posts and useless to view on sidebar or footer.

As we shared in our previous article that How To Pick Most Used Tags In WordPress Without A Plugin? So now without any more preface, pick the snippet and add it where you want to show and customize it with your desire.

Table of Contents

Features:

1.) Pure PHP Code.
2.) No Plugin.
3.) Quick To Load.
4.) Work On Every Page.
5.) Will Not Work Inside WP Loop.
6.) Two Piece Of Code.
7.) Fully Customizable.
8.) No Conflicting.
9.) Pick Most Post Category.
10.) Best For Sidebar And Footer

<!-- Start Limited List Of Most Used Categories -->
<?php
function top_categories() {
 $categories= get_categories();
 if (empty($categories))
 return;
 $counts = $categories_links = array();
 foreach ( (array) $categories as $categories) {
 $counts[$categories->name] = $categories->count;
 $categories_links[$categories->name] = get_category_link( $categories->term_id );
 }
 asort($counts);
 $counts = array_reverse( $counts, true );
 $i = 0;
 foreach ( $counts as $categories=> $count ) {
 $i++;
 $categories_link = clean_url($categories_links[$categories]);
 $categories = str_replace(' ', '&nbsp;', wp_specialchars( $categories));
 if($i < 11){
 print "<li><a href=\"$categories_link\">$categories ($count)</a></li>";
 }
 }
}
?>
<ul>
<?php top_categories(); ?>
</ul>
<!-- End Limited List Of Most Used Categories -->

Customization:

Change 11 with your desired no of categories that you want to pic. Always add 1 more as 11 mean that to pick only top 10 categories.

Recommended For You:
How To Completely Remove 404 Not Found Pages In Google WebMaster?

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *