Echo Category Nicename

*get_the_category();* is designed to return multiple categories. You have to provide index for deciding which categories’ nicename you want to echo. Something like below, $category = get_the_category(); echo ‘<img src=”‘.get_bloginfo(‘template_directory’).’/images/categories/’.$category[0]->category_nicename.’.png”>’;

Pretty URLs with Categories and Tags

You could do it manually in your .htaccess although I’m not sure how. In the past I have been able to use partially pretty urls by doing http://www.mydomain.com/country/america/?city=new_york I would imagine it would easy enough to use mod_rewrite to prettify that even further. UPDATE: Check this out it looks like it will do exactly what … Read more

How can I include custom category and tag base in template files?

We were able to get custom category and tag base names using: get_option(‘category_base’, ‘Categories’) get_option(‘tag_base’, ‘Tags’) We wrapped these functions in ucwords() in order to capitalize the base name and replaced “_” with “”: ucwords(str_replace(‘_’,’ ‘,get_option(‘category_base’, ‘Categories’)) ucwords(str_replace(‘_’,’ ‘,get_option(‘tag_base’, ‘Tags’)) Finally we wrapped all this with the code for localization and added the single cat/tag … Read more

How to correctly display category’s slug as a class?

The filter is used wrong. For the filter the_category the correct parameters are “list”, “seperator” & “parents”, not “post id” Next add_filter has 4th parameter which tells wordpress the number of arguments the function will accept, defaulting to 1. So in your case $post_id will always be false. Then get_the_category returns the categories of the … Read more

Display category and associated post listings

$categories = get_categories(); foreach($categories as $c) { echo ‘<h2>’. $c->name . ‘</h2>’; $posts = get_posts(array( ‘category’ => $c->term_id, ‘numberposts’ => 5 )); foreach($posts as $post) { echo $post->post_title; } ?> <a href=”https://wordpress.stackexchange.com/questions/70590/<?php echo get_category_link($c->term_id);?>”> View all posts in <?php echo $c->name;?> </a> <?php }