I'm trying to combine two types of content in a category archive, essentially injecting a second stream of content into the archive, but I can't get pagination to work. Say I have 15 posts, and 10 of a second type (lets call it 'stream'). If posts_per_page is set to 20, it will show the first 20 combined, but the second page doesn't exist and I get a 404. I know the obvious way to do this is using the pre_get_posts hook, and modifying the query before it gets run. Problem is the second type of content is a custom table (not my idea, helping a coworker) and it would be a ton of work to update it to a post type.

I've already worked through all the filters and actions that are called on the category archive, and nothing makes subsequent pages show. Using the found_posts filter, I've returned the combined count if on a category archive, but that doesn't work. If I set found_posts in pre_get_posts, I can see by printing $wp_query that max_num_pages gets updated to the correct value, but I still get a 404.

Any ideas?

1 Answer 1


The post_type parameter for WP_Query can accept an array of post types. This would allow you to combine both streams into a single query which should resolve your current dilemma with pagination.

$query = new WP_Query( array( 'post_type' => array('page','post') ) );
  • The second post type is a custom table, not a custom post type.
    – Tim
    Sep 30, 2015 at 21:29
  • Ah, my apologies for missing that in your original question. Rethinking.
    – dswebsme
    Sep 30, 2015 at 21:31
  • I don't think native WP pagination is going to work with the custom table in the mix. I believe the 404 stems from WordPress trying to calculate a second page where the numbers aren't adding up properly. To work around this you might try setting up a custom variable, passed as a unique query string or URL pattern. When the category page sees this parameter you should be able to modify the view to reflect a second page of results. I'll provide a code example in a new answer when I get back to my desk.
    – dswebsme
    Sep 30, 2015 at 21:54

Your Answer

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

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