Display wordpress category name without link

January 23, 2009

When you’re using the the_category( ) function to display the category name of a post, a link to the category archive is automatically created by WordPress. While this is a good thing in most cases, what if you don’t want to create a link? Here’s an easy way to do it. To display the category name without haveing a link to the category archive being automatically created, simply open replace the_category( ) by the following code: <?php $category = get_the_category(); echo $category[0]->cat_name; ?>  Read More →

Limit search to specific categories of wordpress

January 23, 2009

If for some reason, you’d like to exclude some categories from searches, you have to tweak WordPress a bit because there’s no built-in solution to this problem. Happilly, here’s a code to do that job. Replace the categories IDs on line 3 and paste the following code on your search.php template: <?php if( is_search() ) : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("s=$s&paged=$paged&cat=1,2,3"); endif; ?>  Read More →

Remove category from your WordPress url

January 8, 2009

Ever wanted to be able to finally remove the useless /category/ from your WordPress categories permalinks? If yes, read on and get ready to hack your .htaccess file. By default, WordPress category permalinks are displayed that way: http://www.livexp.net/blog/category/wordpress As you can see, the category in the url is pretty useless. Here’s how to remove it: First backup your .htaccess file. Then, open it and append the following line: RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L] Once saved, your... [Read the full story]

Highlight the current category of wordpress

December 29, 2008

Most wordpress readers like to know where they are on a website. To help them knowing what they’re exactly browsing right now, you should definitely highlight the current category. It is very easy to do. When you’re browsing a category, WordPress automatically add a current-cat css class to the <li> element. So the only thing you have to do is to edit your style.css file and add a style for the current-cat class: #nav .current-cat{ background:#999; color:#222; text-decoration:underline; } Now your... [Read the full story]

List WordPress category feeds

November 25, 2008

Let’s see how we can list all category feeds by using the good old wp_list_categories() fiunction. Simply paste the following code anywhere on your theme. It will output a list of your categories with a link to the category rss feed. The two parameters used here are: feed_image: The url of the image to display as a link to your feed. feed: The feed format. <?php wp_list_categories('feed_image=www.livexp.net/rss.gif&feed=XML Feed&optioncount=1&children=0'); ?>  Read More →

Page 2 of 4«1234»