Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if( is_category() ) : //because this makes only sense in a category archive page
- $cats = array();
- $cat = get_query_var('cat');
- do {
- $cats[] = (int)$cat;
- $cat = get_category($cat)->category_parent;
- }
- while($cat);
- $args = array(
- 'category__and' => $cats,
- 'orderby' => 'post_date'
- );
- $posts = get_posts( $args ); ?>
- <ul>
- <?php foreach($posts as $post) {
- ?>
- <li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title('')?></a></li>
- <?php } wp_reset_postdata(); ?>
- </ul>
- <?php endif; //ends: if( is_category() ) ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement