Add post IDs to returned results

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

Viewing 10 posts – 1 through 10 (of 10 total)
  • Anonymous
    #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
    #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.

    Anonymous
    #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
    #124857

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

    Anonymous
    #124887

    Ok, thank you Trevor.

    Waiting for Ross’s opinion.

    Anonymous
    #125673

    Hi Ross, do you have a suggestion?

    Thanks

    Trevor
    #125679
    This reply has been marked as private.
    Anonymous
    #126665

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

    Could you give me a direction?

    Thanks.

    Trevor
    #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)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.