single.php: how to list all articles of current category in sidebar
-
I’m trying to list all articles of current category in the sidebar of single.php. Also the currently viewed article is higlighted in the list. The problem is that this code lists -all- articles instead of the articles that are in the same category as the article that is currently shown.
<ul> <?php foreach((get_the_category()) as $category) { ?> <?php $catVal = $category->cat_ID; } $IDOutsideLoop = $post->ID; global $post; $myposts = get_posts('category=.$catVal&showposts=999&order=ASC'); foreach ($myposts as $post) { ?> <li<?php if($IDOutsideLoop == $post->ID) { echo " class=\"current\""; } ?>> <a>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php }; ?> </ul>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘single.php: how to list all articles of current category in sidebar’ is closed to new replies.