I have created a new CPT called 'Properties' and have added a new taxonomy called 'Project Categories' which then have subcats called 'Current_projects' and 'Past_projects'. I want to have a button on the archive-property.php page which when clicked shows either one or the other category's related posts.

I used CPT UI to build both the taxonomy and the custom post.

in the archive-property.php, I have the following code:

<?php if( have_posts() ) : ?>
                <div id="post-list" class="columns property-grid">
                    <?php while( have_posts() ) : the_post(); ?>
                        <?php get_template_part( 'partials/content' , 'property' ); ?>
                    <?php endwhile; // while has_post(); ?>

                    <?php the_posts_pagination(); ?>
            <?php endif; // if has_post() ?>

Inside the template partial it just calls the article information (title, excerpt, etc).

This pulls all my postings however in that Custom Post type. How do I have it so that it only pulls posts with 'current_projects'? I plan to have a div/tab system that filters between the two.

1 Answer 1


Right now you are looping the default WP_Query. Better to define the exact query to fetch the exact posts you want. Here is a link to the complete guide of how to use it, and how to use taxonomies: https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters

  • in the array, where it mentions post_type, I set that to my CPT slug?
    – Xero1
    Aug 8, 2019 at 6:17

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.