I'm developping a plugin showing geolocated posts on a leaflet map. I want to add a shortcode parameter to show a map with only the current loop posts' markers. That feature would be great on the search result page for exemple!


Is there a way to get the current page WP_Query arguments? I want to get those arguments to create a new WP_Query and add some more to filter only geolocated posts.

I don't know if it's possible at all, I always create new WP_query objects from scratch.

Thank you!

3 Answers 3


Have you tried using $wp_query ?

global $wp_query;

For a single variable, you can use get_query_var

Or you could try just dumping the $_POST , var_dump( $_POST );

Or maybe var_dump( $GLOBALS['post'] );

  • $wp_query->query_vars is exactly what I asked for :) Thank you!
    – Camille V.
    Jun 8, 2020 at 14:45

I believe you can use rewind_posts() to get the posts from the current query, then amend from there:


This article has a good explanation of rewind_posts(), differentiating it from wp_reset_postdata() and wp_reset_query() : https://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/

  • Thank you for your time, but it was not exactly what I was looking for (I was searching for current WP_query arguments)
    – Camille V.
    Jun 8, 2020 at 14:46

Another alternative is to get it from the query args directly. You can access all of the $args this way.

$query = new WP_Query( $args );

// paged
$paged_arg = $query->query['paged'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.