A lot of people especially my friends had been sending me emails request on how to make full use of their categories in their wordpress blog. Actually, it is simple to tweak the categories in wordpress and integrate it with the wordpress theme. What you need to know is just basic of PHP.
First of all, please download The Wordpress Help Sheet which is very useful for beginner wordpress designer. Download it here
Well in this article I will show step by step in detail coding on what wordpress categories can do for you. No need advanced PHP knowledge but of course please learn them if you want to go further.
Hopefully this will be a helpful guide that you can refer to whenever you’re developing a new theme.
Where to Get the Category id or numbers from WP Dashboard
You can get the category numbers in from the WP dashboard by just hovering on the specific category name in categories section and look at the bottom of your browser. See below image for guide.

How to Show Only Post Titles on Category Pages:
Another option is to only show post titles. You can do that by using this code:
1 | <?php the_title() ?> |
Most likely your theme already has this code surrounded by a link to the permalink of the post. So what you will want to do is just delete the code that calls the excerpt or the content and leave the title and link intact.
How to Show Post Excerpts on Category Pages:
To avoid duplicate content and to reduce the length or category pages, many bloggers choose to show excerpts instead of full posts. It’s a simple change. Find this code:
1 | <?php the_content() ?> |
And change it to this:
1 | <?php the_excerpt() ?> |
How to Exclude Specific Categories from Your Category List:
Most professional or personal blogs include a list of their categories in the sidebar or header as a menu to help visitors find the content. However, there may be times when you want to exclude certain categories from the list. Fortunately it’s a very simple change.
This is the code to display all categories.
1 | <?php wp_list_cats(); ?> |
This is the code to exclude categories number 4 and 5.
1 | <?php wp_list_cats('exclude=4, 5'); > |
How to Remove a Category from the RSS Feed:
Okay, for rss feed there are tons of plugin out there but if you are a theme designer then learn how to make it manually.
To exclude a category, use this URL for your feed:
http://example.com/feed?cat=-4
That would exclude category number 4. To exclude multiple categories, use a URL like this:
http://example.com/feed?cat=-3&cat=-4&cat=-5
How to Exclude Posts in a Category from Appearing on the Homepage:
There may be situations where you want to exclude posts from the front page based on their category.
To exclude a category from the loop on the front page, find this code:
1 | <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> |
and change it to this:
1 2 | <?php query_posts('cat=-4'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> |
This will exclude posts in category number four from being displayed on the front page.
How to Show Links to the Most Recent Posts from a Specific Category in the Sidebar:
Many blogs use simple WordPress coding to show links to the most recent 5 or 10 posts in the sidebar. You can adapt this to include or exclude specific categories.
To show the 10 most recent posts in category number 4, use this code:
1 2 3 4 5 6 | <?phpquery_posts('cat=4&showposts=10'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul> |
To exclude category number for, simply put a minus sign (-) in front of the category number, like this:
1 2 3 4 5 6 | <?phpquery_posts('cat=-4&showposts=10'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul> |
The code above will show the 10 most recent posts from all categories except number four. To exclude multiple categories simply add a comma, like this:
1 2 3 4 5 6 | <?phpquery_posts('cat=-4,-5&showposts=10'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul> |
How to Set Up a Separate Feed for a Category:
If you exclude a category from your main feed you may also want to offer a separate feed for the one excluded category (again, this is common for sideblogs). WordPress will easily give you the feed for any one category by using a URL like this one:
http://example.com/category/nameofyourcategory/feed/
or
http://example.com/category/nameofyourcategory/?feed=rss2
If you want, you can take that URL and run it through FeedBurner and treat it like any other feed.
Note
Well hope this article help everybody. For comments and question feel free to leave below.
Resource was taken from http://vandelaydesign.com/blog/wordpress/category-hacks/
|
What To Do Next? Well start by having a drink on us and share this article. |
|
|
Related Posts Check out some more nice article and tutorial that you might like |












Leave a Reply
Some comment may need to be approved before showing