Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

Please Consider this snippets of code.


<?php 
     $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>
 </li>
    <?php endwhile; ?>
share|improve this answer
add comment

Your Answer

 
discard

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.