My page here: https://blackfreedom.proquest.com/category/civil-rights-and-black-power-movements/activism/selma-demonstrations-and-marches/

is displaying all pages on the site, not just the ones that are associated with this 'Selma' category. Which piece am i missing? Should I be using WP_query instead? I'd like to have this dynamic so that all of category pages show the correct pages associated with their cats.

Putting this in my archive.php code:


        $cat = get_query_var('cat');
        $PozCat = get_category ($this_category);
        if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

        <li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
        <p> <?php the_excerpt()?> </p>
    <?php endwhile; endif; ?>
  • $this_category is not defined; try working with: $PozCat = get_category ($cat);
    – Michael
    Oct 3, 2020 at 1:58
  • Interesting. It's now showing the pages, but only ones that are not associated with the current category. Oct 3, 2020 at 22:22

1 Answer 1


Resolved using this:

            $current_category = get_queried_object(); ////getting current category
$args = array(
        'post_type' => 'page',// your post type,
        'orderby' => 'menu_order',
        'order' => 'DESC',
        'cat' => $current_category->cat_ID // current category ID
$the_query = new WP_Query($args);
   while($the_query->have_posts()): $the_query->the_post();
    echo '<h2><a href="'.get_the_permalink().'">'.get_the_title().'</a></h2>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.