Display category slug, description and parent
-
The original code that will display 3 categories which shows 1 recent post for each category:
<?php $display_categories = array(5,6,7); foreach ($display_categories as $category) { ?> <div class="clearfloat"> <?php query_posts("showposts=1&cat=$category"); $wp_query->is_category = false; $wp_query->is_archive = false; $wp_query->is_home = true; ?> <h3><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></h3> <?php while (have_posts()) : the_post(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> </div> <?php } ?>From that code, I dont know what code to replace on the capitalize word below to display parent, slug and description of the listed category:
<?php $display_categories = array(5,6,7); foreach ($display_categories as $category) { ?> <?php query_posts("showposts=1&cat=$category"); $wp_query->is_category = false; $wp_query->is_archive = false; $wp_query->is_home = true; ?> <h3><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></h3> <?php echo CATEGORY PARENT;?> <?php echo CATEGORY SLUG;?> <?php echo CATEGORY DESCRIPTION;?> <?php while (have_posts()) : the_post(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> </div> <?php } ?>————————-
what i did so far:
1. I have no problem in pulling the category description:
i use this code: <?php echo category_description(‘$category’); ?>
2. but for the category parent and slug(nicename) i cant figure out how.
from wordpress codex (http://codex.wordpress.org/Template_Tags/get_category_parents), if I use this code:
<?php echo(get_category_parents($cat, TRUE, ‘ » ‘)); ?>this will result to:
Internet » Blogging » WordPress »How can I make it display Category Parent Only (eg. ‘Internet’)?
3. on pulling the category slug, i’m clueless.
thanks for the upcoming responses! any help would be greatly appreciated! =)
The topic ‘Display category slug, description and parent’ is closed to new replies.