Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Add post IDs to returned results

  • This topic has 9 replies, 3 voices, and was last updated 7 years ago by Ross.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Senac São Paulo
    #124614

    Hello guys,

    I have exactly the same problem of this topic (resolved):

    https://support.searchandfilter.com/forums/topic/adding-post-ids-to-returned-results/

    I did what you suggest, but it returns all posts instead my array on $args[‘post__in’].

    If I use $args[‘p’] or $args[‘meta_query’] for example, it works fine.

    Here is my code:

    
    function filter_function_name( $args, $sfid ) {
    
    		//if search form ID = XX, the do something with this query
    		if ( $sfid == 2817 ) {
    
    			$args['post__in'] = array(3662, 3667); // for example
    
    		}
    
    		return $args;
    	}
    	add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 200 );
    

    Thanks in advance 🙂

    Trevor Moderator
    #124633

    I think I would be inclined to output (using print_r) to see what is in the post__in array before and after you change it.

    Senac São Paulo
    #124848

    Hi Trevor.

    I tryed using print_r and var_dump in functions.php but nothing is showing up on front-end. Like below:

    
    
    function filter_function_name( $args, $sfid ) {
    
    		//if search form ID = XX, the do something with this query
    		if ( $sfid == 2817 ) {
    
    			var_dump($args['post__in']);
                            print_r($args['post__in']);
    
    		}
    
    		return $args;
    	}
    	add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 200 );
    

    I tryed using var_dump($args['post__in']); in my custom page template and it returns NULL.

    Trevor Moderator
    #124857

    I think I would have to refer this to Ross, the developer, for his comments.

    Senac São Paulo
    #124887

    Ok, thank you Trevor.

    Waiting for Ross’s opinion.

    Senac São Paulo
    #125673

    Hi Ross, do you have a suggestion?

    Thanks

    Trevor Moderator
    #125679
    This reply has been marked as private.
    Senac São Paulo
    #126665

    Hi Trevor and Ross, It’s been a while since I sent my question.

    Could you give me a direction?

    Thanks.

    Trevor Moderator
    #126667
    This reply has been marked as private.
    Ross Moderator
    #127568
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Add post IDs to returned results’ is closed to new replies.