1

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.

1

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>
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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