0
votes

I have a custom post type called 'Case Studies' that I'm using for case studies and the default post type ('post') for blog posts. I have a custom taxonomy called 'product_categories' which is used for blog posts and case study posts.

On my category template 'taxonomy-product_categories.php' I want to separate 'blog' post excerpts from 'case study' post excerpts but I can't find a way to query the post archive?

I've tried is_post_type_archive(), is_archive(), is_category() and is_tax() but none of them filter the posts.

I've also tried querying the posts but it just loads all posts from that post type.

2
When you say separate so you mean remove one of the post types, or list on efiirst then the other? Can you post a sample of your code please?Paul
Sorry, I should have made that clearer. By separate, I mean, keeping the blog posts in a right-hand column and the Case study post in the left-hand column. As for a code sample, I'm using the standard 'if have posts while loop'.Rob

2 Answers

0
votes

If you are within the loop you could identify a post using is_single() and the case studies by using is_singular('case-study') but I would say to keep them in left and right hand columns and for ease of styling then 2 separate loop might work best.

0
votes

You should be able to distinguish post types using the post object in your while loop if you're using the standard like this:

    <?php while ($query->have_posts()) {
      $query->the_post(); ?>

You could so something like this in your while loop:

    <div class="left-column">
       <?php
          if ($post->post_type === 'case-studies') {

            // Show your case study excerpts

          } else {

               // No content found message
          }

       ?>
     </div>

     <div class="right-column">
       <?php
          if ($post->post_type === 'post') {

            // Show your post excerpts

          } else {

               // No content found message
          }

       ?>
     </div>