list posts in ALL current categories
-
Hi, i’m looking for a piece of code to put in the sidebar that lists all post that are in the current category.
There’s a lot of examples that do this, but i need one that lists the post that are in the same combination of categories. For example if you visit the page …/category/aaa/bbb/ the sidebar lists al posts that are in catogry aaa AND bbb. All code i’ve seen so far list posts that are in category aaa OR bbb or that only take the first category.
Like the one i’m using now;<?php $category = get_the_category(); //get first current category ID $this_post = $post->ID; // get ID of current post $posts = get_posts('orderby=post_date&category=' . $category[0]->cat_ID); ?> <?php foreach($posts as $post) { ?> <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title('')?></a></li> <?php } wp_reset_postdata(); ?>
Does anyone have a clue?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘list posts in ALL current categories’ is closed to new replies.