WP Query Console – Quickly Test WordPress Queries

Home » Blog » WP Query Console – Quickly Test WordPress Queries

It’s common while working on theme and plugin development, as it involves working with WordPress queries. A most common way to test is ‘var_dump( )’ to test the output, or refresh the page and see the output, but then we thought of creating a handy script long back to make it less boring. The idea was to have something like an SQL client kind of thing, so that we can write the query and see the output.

Recently, we converted it into a WordPress plugin called “WP Query Console,” which is available on the plugin directory. You can quickly install it right away from your dashboard. Also, we have published the code on GitHub for other developers to contribute and collaborate.

Once the plugin is installed and activated, a new option is added to the main menu, “Query Console”. No settings page, only one page to input and test your queries. The plugin page provides you with a Text editor with code highlight to input your query arguments in the array form and select the type of query you would like to execute from the drop-down (WP_Query, WP_User_Query, WP_Comment_Query, WP_Term_Query, WP_Network_Query, WP_Site_Query). Click on execute to get the query output on the screen. Cool, isn’t it?

Under the hood, the plugin executes the actual query using the arguments provided against the respective query type and sends the output to the screen as JSON. You can test queries and validate them before implementing them into your final code.

This plugin might seem silly and pointless, but it might help someone. We plan to add more features and improvements over time.

NOTE:
This plugin is meant for development purposes only. To be used on your local / development server.

Ajit Bohra Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *