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 the code examples out there are given as an 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:

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 );

Replace array( '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?



For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
  • Is it possible to setup the easypost with ACF?
    + setup a filter showing only posts if a second ACF ist true?

  • Hey Sridhar, thx for the tut 🙂
    I’d like to show future events in my EasyPost module and therefore need to input the current date and a future date into the query. Is it somehow possible to preprocess the query?

  • >
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
    %d bloggers like this: