• Resolved Rev. Voodoo

    (@rvoodoo)


    Here’s something I just noticed, not sure if it’s an intended behaviour/result of my lack of knowledge

    I had 3 CPTs, changed over all my CPT page templates to be archive-CPT.php and removed the queries. Turned on has archive, and all was right with the world.

    On one of my CPTs, I needed 30 posts per page, so I dropped a simple query into the archive template to display 30 posts. That had the unintended consequence of showing all posts.

    Seems if any simple query is used, the archive becomes an archive for all posts, not just the CPT any longer.

    Is there a different way to do it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you’re going to use query_posts(), you can’t do this:

    query_posts('post_per_page=30');

    What that does is load up the normal posts! Instead, you’ll want to append $query_string to your query_posts() call, or at least continue to pass a post_type=your_post_type.

    That said, changing the number of posts per page via query_posts is fraught with issues, because WordPress has already counted paging and such by that point. You’d be better to hook into request, parse_request, pre_get_posts, or even the posts per page value (for that post type) to specify pagination changes.

    Thread Starter Rev. Voodoo

    (@rvoodoo)

    Thanks for the intel! Learnin’ every day!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘3.1 RC2 Adding any query to CPT archive removes archive functionality’ is closed to new replies.