Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried using wp_list_categories, but that just gives me a list of the categories. I currently have this code in my category-recipes.php file:

<ul class="subcats-list">
            <h2 class="subcats-title"><?php echo get_cat_name(38); ?></h2>
                <?php
                $recipes = new WP_Query();
                $recipes->query('showposts=5&orderby=rand&cat=38&post_type=recipe');

                while ($recipes->have_posts()) : $recipes->the_post(); ?>
                    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
                <?php endwhile; ?>

        </ul><!-- subcat -->

I was thinking about putting a link tag before the get_cat_name but I am not sure what to include in it.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use get_category_link. Your code (relevant part) will look like:

        <h2 class="subcats-title"><a href="<?php echo get_category_link(38); ?>"><?php echo get_cat_name(38); ?></a></h2>
share|improve this answer
    
Thanks. Worked. I had that but did not include the echo before get_category_link which resulted in staying on the same parent category page... –  chris_s Jun 17 '11 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.