WordPress.org

Support

Support » How-To and Troubleshooting » How to link to a category?

How to link to a category?

  • jessn
    Participant

    @jessn

    Hi guys! I’ve spent the better part of a week trying to figure out how to do this and I’m just stuck. I’m trying to display a list of categories, the children of parent category ‘5’, along with their recent posts. However I want the category titles and the recent posts to link to the category page which will pull up all posts filed under that category. And I can’t figure out how to do it!

    What do I need to put inside the a href=”…” to find the name of the current category that’s being looped through and place that name inside? MANY THANKS FOR ANY HELP!!

    <?php $categories = get_categories("child_of=5"); foreach ($categories as $cat) { ?>
    <?php query_posts("cat=$cat->cat_ID&showposts=10&order=ASC&orderby=name"); ?>
    		<h2><?php single_cat_title(); ?></h2>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<a href="linktothespecificcategory"><img src="image"></a>
    
    		<?php endwhile; ?>
    <?php }?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to link to a category?’ is closed to new replies.