I have 3 pages, "Page 1" shows custom post-type "articles", "Page 2" shows custom post-type "tips", and "Page 3" shows both custom post-types. This is done conditionally with a custom loop in page.php.

Both post-types have the default "category" taxonomy as well as an extra custom taxonomy for each type.

When you're on a page and click on the category link associated to a post you go to /category/cat/. My current category.php template pulls in both "articles" and "tips" that match that category. What I want to do is if you click on the category when you're on 'Page 1" then only show "articles" in the category template, if you're on "Page 2" then only show "tips". And on "Page 3" show both.

I've been trying to do this with pre_get_posts but I'm not sure how to implement it. Should I create different templates for each page? Should I just POST an extra variable and modify the query in category.php? Any ideas are welcomed.

1 Answer 1


Please Consider this snippets of code.

     $myarticles = new WP_Query( 'post_type=myarticles&orderby=date&order=DESC&cat=4' );    
         while ($myarticles->have_posts()) : $myarticles->the_post();
                $postTitle = get_the_title();
            $postid = get_the_id();
        $postContent    = get_the_content();

 <li><p><?php echo $postTitle;  ?></p>
<a href="#"><?php the_post_thumbnail(array(219,143)); ?></a> 
                  <p><?php echo $postContent;  ?></p>
    <?php endwhile; ?>

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.