Added by on May 26, 2012

In this article we will share the most wanted category hacks and plugins for WordPress which you can use in your themes. These snippets of codes are a lifesaver in many situations when it comes to modifying a theme.

1. Display Certain Categories in a Menu

category hack menu in wordpress

In many cases, users only want to display certain categories in their navigation menu at the top of the page. There are limited spots, that can only be filled by top categories, but if you use the default wp_list_categories code, it will show all categories. This is why this hack below comes in very handy when you want to create a navigation menu and only display certain categories.


 

<ul style="float:left; width:730px;">
 <?php wp_list_categories('orderby=name&include=7,9,19,16,1,5,17,23'); ?>
 </ul>

Note, you can also change the ‘include’ text to ‘exclude’ and show all categories and exclude those that you don’t want displayed. The numbers displayed in the code are the category IDs. Remember since WordPress shows categories in a list format, you will need to edit the CSS in order to make it work.

2. Display Category in a Dropdown Menu

category dropdown

Some blogs have a lot of categories which they can’t display in their sidebar. Or some bloggers do not want to take up a lot of space displaying categories. This option allows them to have a select menu, dropdown menu, for categories. See WordPress Codex for details.

 

<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>

 

3. Exclude Certain Categories from Being Displayed in a Loop

Your blog page shows recent posts from all categories. If you want to have a separate page for some reason, or do not want to display certain categories, you can use the following code, and it will exclude a certain category from being displayed in a Loop. Just change the category IDs.

<?php if ( have_posts() ) : query_posts($query_string .'&cat=-13,-26'); while ( have_posts() ) : the_post(); ?>

4. Display the Most Recent Posts from a Specific Category

balkhise

This code comes in handy when you want to display posts from a specific category on your homepage, or in your sidebar. A live example of this code can be seen at Balkhis.com. The code below will show 1 post with the excerpt from category 3. You can modify the numbers as you desire.

<?php
 query_posts('showposts=1&cat=3');
 while(have_posts()) : the_post();
 ?>
 <ul>
 <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<ul><li><?php the_excerpt(); ?></li>
 </ul>
 </li>
 </ul>
 <?php endwhile; ?>

To only show links from the category use the code below:

<?php
 query_posts('showposts=1&cat=3');
 while(have_posts()) : the_post();
 ?>
 <ul>
 <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
 </li>
 </ul>
 <?php endwhile; ?>

5. Exclude a Specific Category from RSS Feeds

catexcluder

There are certain categories that contain maybe link love and others which most of your users are not interested in. This is the option to satisfy those users. You can exclude a specific category by using a plugin called Advanced Category Excluder, or you can do it manually by using the code below:

http://example.com/feed?cat=-5

To exclude multiple cateogries, just use the ampersand symbol:

http://example.com/feed?cat=-4&cat=-5

If you don’t want to use the plugin and don’t want to do it manually with the link. There is another way which you can use by editing your function.php. Paste the following code in it:

function myFilter($query) {
 if ($query-&gt;is_feed) {
 $query-&gt;set('cat','-5'); //Don't forget to change the category ID =^o^=
 }
 return $query;
 }
add_filter('pre_get_posts','myFilter');

 

6. Make a Separate RSS Feed for Each Category

Often times bloggers wonder how to make separate RSS feed for their category. Because sometimes your user only visits your website for the design category, but you have ten other categories that the user is not interested in. This hack will take care of this issue. (Source)

All you have to do is add the word feed in front of the category URL, and it will take you to the feed for that specific category.

If you want to display a RSS icon in front of category listings then use the code below:

<?php wp_list_categories('feed_image=http://www.mildtheme.com/image.gif&feed=XML Feed&optioncount=1&children=0'); ?>

You must make sure to change the URL of the image because this will display RSS icon in front of each category.

7. Assign an Author to a Specific Category

On Blogs that have multiple authors, it is wise to assign authors to specific categories to avoid confusion. This plugin limits the user to publishing into the categories he/she is assigned.

Check out the plugin Userextra

8. Show Post Excerpts on Category Pages

Sometimes in order to prevent duplicate content, and make your category pages easy to browse, it is recommended that you use excerpts instead of displaying full posts. Category pages are indexed like normal blogs are in chronological order, so if you have a post that is 1000 words and 25 images, and you are displaying 5 posts on each page. It will be a hassle for your user to go through category archives. Therefore we suggest you show excerpts instead of full posts on category pages. Then you just direct them to the single post page where full text is written. It also helps pageviews for those who are addicted with stats.

First you would need to open index.php and locate this code:

<?php the_content() ?>

and replace it with:

<?php the_excerpt() ?>

Now when you write posts, just write a custom excerpt to make it more interesting.

9. Show Category Icons

category icons

Pictures make a site more lively which is a given which is why blogger might want to associate pictures with their category. This plugin lets you associate a specific icon of your choice to a designated category. You can use this plugin to list categories by icon with or without names, and much more.

10. Display Category Description in Template

Displaying category description on category pages are considered to be more SEO Friendly. But this is often used when running a modified theme in which you have subcategories within a category. When you have separate category pages customized displaying category description is always a good edition.

This is the description that you type when creating a category in your WordPress admin panel.

Add the following code in your archive.php / category.php whichever one is more appropriate for you:

<?php echo category_description(); ?>

 

Leave a Reply

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

*

17 Comments

  • burberry backpack 1 year ago

    Definitely, what a fantastic website and instructive posts, I surely will bookmark your website.All the Best!

  • MBT Shoes 1 year ago

    Hello Many thanks for presenting ready information. I am now bookmarking this website pertaining to future reference point.good luck with this particular good materialwebsite.

  • Louis Vuitton Bags 1 year ago

    One of the better to make a speedy comment to be able to express thanks for you for the people wonderful tips you might be submitting here. My own time consuming net investigation features towards the end the whole day been recognized with top quality ways of show to my guests. We would say that many individuals prospects are in reality endowed to happens to a fantastic network together with methods. amazing those with beneficial hints. Personally i think quite honored to own employed your internet pages and search towards really far more fabulous min’s reading right here. Many thanks for many things.

  • Dustin Trial 1 year ago

    Good write-up, I’m normal visitor of one’s web site, maintain up the nice operate, and It’s going to be a regular visitor for a long time.

  • panik bozukluk 1 year ago

    You made some nice points there. I looked on the internet for the subject and found most guys will go along with with your blog.

  • Backyard Monsters Hack Download 1 year ago

    Useful info. Fortunate me I discovered your site by accident, and I am stunned why this accident didn’t happened earlier! I bookmarked it.

  • lv handbags 1 year ago

    Great post, I like your Blog, Keep on, Thankx.

  • louis vuitton knockoff handbag 1 year ago

    Great article,Thanks for your great information, the contents are quiet interesting.I will be waiting for your next post.

  • радио фреш 1 year ago

    Всичко за радио фреш което искате и можете да прочетете в интернета. Прочетете повече информация.

  • Kemberly Holla 1 year ago

    Thank you for sharing with us, I believe this website genuinely stands out : D.

  • fkawau 1 year ago

    This is the precise 10 Most Wanted Category Hacks and Plugins for WordPress | MildTheme – Download WordPress Themes and WordPress Templates blog for anyone who wants to assay out out roughly this topic. You attention so untold its almost wearying to argue with you (not that I really would want…HaHa). You definitely put a new extend on a substance thats been statute nigh for age. City sundry, just major!

  • Louis Vuitton GM 1 year ago

    Great post, I like your Blog, Keep on, Thankx.

  • fkawau 1 year ago

    This is the straight 10 Most Wanted Category Hacks and Plugins for WordPress | MildTheme – Download WordPress Themes and WordPress Templates blog for anyone who wants to essay out out active this topic. You attention so such its virtually debilitating to represent with you (not that I truly would want…HaHa). You definitely put a new reel on a theme thats been shorthand near for eld. Pleasant squeeze, but high!

  • louis vuitton gm 1 year ago

    Nice post. I learn something more challenging on different blogs everyday.

  • bayan çanta 1 year ago

    If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

  • domain 5 months ago

    I’m not sure exactly why but this site is loading very slow for me.
    Is anyone else having this problem or is it a problem on my end?
    I’ll check back later and see if the problem still exists.