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:
array( '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:
Add a Code Block element (doesn’t matter where – this is just a temporary thing) and inside the PHP & HTML, add
<?php $data = array( 'post_type' => 'page', 'post__in' => array( 2, 5, 12, 14, 20 ) ); echo build_query( $data ); ?>
array( 'post_type' => 'page', 'post__in' => array( 2, 5, 12, 14, 20 ) ) with your custom query.
Save the entry and view it on frontend. Copy the generated code.
Edit your Easy Posts element. Go to Query > manual, paste the code.
Apply Query Params.
Easy Posts should now use the query you provided.
Delete the Code Block.