Closed pshemek closed 4 years ago
Hello!
Thank you for your work on this powerful and flexible plugin.
I have the following problem.
When I create a custom query, geo location component works well:
$q = new WP_Query( [ 'post_type' => 'article', 'geo_mashup_query' => [ 'country_code' => 'US' ] ] );
However, I need to use geo_mashup_query in the main query of archive page. Normally, I would use pre_get_posts hook for this purpose but when I'm trying:
add_action( 'pre_get_posts', 'custom_filters_query' ); function custom_filters_query( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'article' ) ) : $geo_mashup_query = [ 'country_code' => 'US', ]; $query->set( 'geo_mashup_query', $geo_mashup_query ); endif; }
the results on archive page are not filtered.
What can be wrong? Is it possible to join the main query with geo query?
I think you'll have to use the parse_query action instead of pre_get_posts and set the priority to 9 so your hook runs before Geo Mashup's.
parse_query
pre_get_posts
Hello!
Thank you for your work on this powerful and flexible plugin.
I have the following problem.
When I create a custom query, geo location component works well:
However, I need to use geo_mashup_query in the main query of archive page. Normally, I would use pre_get_posts hook for this purpose but when I'm trying:
the results on archive page are not filtered.
What can be wrong? Is it possible to join the main query with geo query?