WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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; ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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