Make a menu that lists posts by category
-
I am trying to build a menu which lists Posts by Category. The code below does the trick but has an unwanted side effect – code on single.php and page.php loops through all the posts on the site. Can anyone suggest another way to achieve this? I’m trying to post this code to a codebin, but am having problems so here it is for now:
- /” class=”first”>Home
- cat_ID; ; echo get_category_link($cat->cat_ID);?>”><?php echo $cat->name; ?>
<?php
$categories = get_categories();
foreach ($categories as $cat) {?>-
<?php
- ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?>
$catID = $cat->cat_ID;
query_posts(“cat=$catID”);
while (have_posts()) : the_post();
?><?php endwhile; ?>
<?php } //end foreach ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Make a menu that lists posts by category’ is closed to new replies.