Pull category slug, description and parent
-
i’m modifying a code from theme mimbo2.2
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 $values = get_post_custom_values("Image"); if (isset($values[0])) { ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="" /></a> <?php } ?> <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?>»</a> <?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 those 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 $values = get_post_custom_values("Image"); if (isset($values[0])) { ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="" /></a> <?php } ?> <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?>»</a> <?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 ‘Pull category slug, description and parent’ is closed to new replies.