Forums › Forums › Search & Filter Pro › Add post IDs to returned results
Tagged: post__in, sf_edit_query_args
- This topic has 9 replies, 3 voices, and was last updated 7 years, 3 months ago by Ross.
Viewing 10 posts - 1 through 10 (of 10 total)
-
Anonymous(Private) August 4, 2017 at 9:57 pm #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 🙂
Anonymous(Private) August 7, 2017 at 4:16 pm #124848Hi 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. -
AuthorPosts
Viewing 10 posts - 1 through 10 (of 10 total)