When you want to write a manual query in an Easy Posts element, the input needs to be a valid query string.

Almost all the code examples out there are given as arrays that contain key-value pairs like the following:

	'post_type' => 'page',
	'post__in'  => array( 2, 5, 12, 14, 20 ),

The above will fetch Pages that have the specified IDs.

But how do we convert the above to a query string that can be added in Easy Posts?

WordPress’ build_query function to the rescue.

Here’s how this can be used:

Step 1

Add a Code Block element (doesn’t matter where – this is just a temporary thing) and inside the PHP & HTML, add

$data = array(
	'post_type' => 'page',
	'post__in'  => array( 2, 5, 12, 14, 20 ),

echo build_query( $data );


	'post_type' => 'page',
	'post__in'  => array( 2, 5, 12, 14, 20 ),

with your custom query.

Step 2

Save the entry and view it on frontend. Copy the generated code.

Step 3

Edit your Easy Posts element. Go to Query > manual, paste the code.

Apply Query Params.

Easy Posts should now use the query you provided.

Step 4

Delete the Code Block.




Need help implementing a tutorial in your site or want to hire me for custom work?


Find the article helpful and wish to donate?



You need to be logged in to view and post comments.
Not a member yet? Join here.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: