0

I've looked over numerous questions and answers on problems somewhat related to this but can't seem to find the same situation or solution.

I have a custom taxonomy that needs to have an archive page that can display both custom post types and regular posts, but not in the same section. Basically there needs to be a clear difference between the CPT-posts and regular posts.

For example, if "movie guides" is the custom taxonomy, "ben affleck" is a movie guide, and "Movies" are custom post types on: website.com/movie-guides/ben-affleck

I would like that page to also have regular posts that are in the "ben affleck" movie guide taxonomy, but at the bottom of the page, in a different section for regular posts/post thumbnails. So part of the page would have Movies (posts from the CPT "Movies") with Ben Affleck, and after that would be post snippets from posts about Ben Affleck.

I've found information to just pull both types of posts on the same page together, but wasn't sure how to separate them in the template which is what I'm really looking for.

UPDATE: So far I've taken part of the theme's default category template and created taxonomy-{taxonomy_slugname}.php, which has pulled the CPTs onto the page, but now I can't figure out how to add posts since it's pulling the CPT's via "get post." My theme is Braxton, if that helps.

5
  • Good question. What have you tried so far and where's your code? Have you read this codex.wordpress.org/Class_Reference/WP_Query Jul 15, 2014 at 9:00
  • how would expect this to paginate, or would all results be on a single page?
    – Milo
    Jul 15, 2014 at 15:59
  • @BradDalton I have but it doesn't seem to help. Updating my question with more information on what has been done.
    – howdydoo
    Jul 17, 2014 at 10:17
  • @Milo I hadn't gotten to that part yet. I was hoping to have the CPT's paginate in a group of 9 or so, with the regular post snippets still below them/below the pagination.
    – howdydoo
    Jul 17, 2014 at 10:17
  • The problem you'll have with pagination is that when the main query runs out of posts, subsequent pages will 404. Your secondary query can never have more posts than the main query.
    – Milo
    Jul 17, 2014 at 14:05

1 Answer 1

0

Use a new query outside the loop like this one

$query = new WP_Query( 'category_name=ben affleck;post_type=post' );

if ( $query->have_posts() ) : while $query->have_posts() : $query->the_post();

 // Loop output goes here

endwhile; endif;
3
  • Please note category_name is not the name of the category, but the slug Jul 17, 2014 at 11:23
  • Yea my bad, had to say that.
    – Augus
    Jul 17, 2014 at 12:33
  • You have a syntax error in your query parameters, semicolon should be an ampersand.
    – Milo
    Jul 17, 2014 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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