• I love your plugin, but after all the time I used it, I found out that there really is a bug (tried out a lot) when I use a post__in filter for “gmw_pt_search_query_args”.

    Here’s a simplified example (usually I use the favorite posts of the current user instead of just typing 5 post IDs in the code).
    Just change the PostIDs to PostIDs that exist in your database:

    function gmw_filter_favorites( $query_args, $gmw ) {
    	if ( empty( $_GET['favorites'] ) )		
    		return $query_args;
    
    	//replace 1 with your form ID
    	if ( $gmw['ID'] != 1 ) 
    		return $query_args;
    
     	$query_args['post__in'] = array(23364,23347,23387,23166,22767);
    
     	return $query_args;
    }
    add_filter( 'gmw_pt_search_query_args', 'gmw_filter_favorites', 10, 2 );

    If no radius is set in the search form of GMW, everything works fine.
    But if I set a maximum distance radius combined with the “post__in” argument, some posts get filtered out that should not.

    For example, my 5 example post ids above do have the following distances in km:
    4.5 / 5.4 / 17.8 / 358.4 / 517.0

    – If I set the distance between 6 and 358 in the search form, I only get the posts with the distances 4.5 and 5.4, bot not 17.8 as it should be
    – If I set the distance between 359 and 516, I only get the posts with the distances 4.5, 5.4, 358 and 517 (which is wrong), but not 17.8 as it should be
    – If I set the distance to 517 or above, everything is correct again and every post is displayed.

    So it looks like it mixes up the distances and sorts out wrong posts.

    There’s no problems with the post. The address is found, longitude/latitude is calculated correctly and everything works fine, as long as I don’t use “post__in”.

    The problem seems to be in the query_clauses function in the gmw-pt-search-query-class.php, that doesn’t seem to work correctly with the post__in argument.

    Can you figure this out?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with post__in query filter’ is closed to new replies.