WP Manifestindependent plugin directory
manifest / developer / wp-combine-queries

Combined Query

WordPress: Combine multiple WP_Query() queries into a single one, through the custom 'combined_query' attribute of the WP_Query class.

by birgire · github.com/birgire/wp-combine-queries · website

70stars
1.3kcomposer installs
10forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/birgire/wp-combine-queries/archive/refs/heads/master.zip

Also on Packagist as birgir/combined-query:

composer require birgir/combined-query

Declares an update source (https://github.com/birgire/wp-combined-queries.git), so updates arrive through the plugin's own updater.

From the readme

Combine Query WordPress plugin - Combine Query Description This experimental plugin allows you to combine multiple WPQuery queries into a single one, using the combinedquery attribute. This started as an answer on Stackoverflow, see here and here. The idea behind this plugin is to combine the SQL queries for each WPQuery() query with UNION or UNION ALL. I first noticed this technique in a great answer on WordPress Development by Mike Schinkel. I use the trick mentioned here to preserve the order of UNION sub queries. This implementation supports combining N sub-queries. Notice about the new 1.0.0 version This version is a total rewrite of the plugin. The WPCombineQuery class has been removed in favour of simply using the combinedquery attribute of the WPQuery class. Now the plugin only supports PHP versions 5.4+. Settings The supported settings for the combinedquery attribute: 'combinedquery' = [ 'args' = [ $args1, $args2, ... ], // Array (default []) 'union' = 'UNION', // String Possible values are UNION or UNION ALL (default UNION) 'postsperpage' = 10, // Integer 1,2,... 'offset' =

Read the full README on GitHub →