Forums › Forums › Search & Filter Pro › Turn off / Ignore Results per page setting
- This topic has 9 replies, 3 voices, and was last updated 8 years, 8 months ago by Ross.
-
Ross Moderator(Private) April 4, 2016 at 11:09 am #41477
Unfortunately not, but you could modify the query using this filter
And add in your own value.
Thanks
Anonymous(Private) April 5, 2016 at 8:44 am #41625Can you please explain more. I have this code now but the number of results don’t change
<?php function results_map_filter( $results_map_args, $sfid ) {
if($sfid==1530) {
$results_map_args = array(
‘post_type’ => ‘posttype’,
‘posts_per_page’ => -1,
‘post_status’ => ‘publish’,
‘cache_results’ => true,
‘no_found_rows’ => true
);
}
return $results_map_args;
}
add_filter( ‘sf_edit_query_args’, ‘results_map_filter’, 10, 2 );
$results_map = get_posts( $results_map_args );
if (have_posts() ) :
?>Trevor(Private) April 5, 2016 at 8:57 am #41626I have no idea if your code is roughly correct, but it is not semantically correct.
It would look like this to be correct from a PHP point of view, I think:
<?php function results_map_filter( $results_map_args, $sfid ) { if($sfid==1530) { $results_map = get_posts( $results_map_args ); if (have_posts() ) { $results_map_args = array( 'post_type' => 'posttype', 'posts_per_page' => -1, 'post_status' => 'publish', 'cache_results' => true, 'no_found_rows' => true ); } return $results_map_args; } add_filter( 'sf_edit_query_args', 'results_map_filter', 10, 2 ); ?>
You would use this in your child theme functions.php file, which should already have the opening PHP tag
<?php
, so you wouldn’t need that from the code, and it is NOT normal to close the PHP tags?>
at the end of the functions.php file as this can cause a site to crash.I could well be wrong with the code though.
Ross Moderator(Private) April 5, 2016 at 9:54 am #41634There shouldn’t be a custom query inside the filter itself, the filter is used to modify the arguments before they get passed to a query – the code should look like:
function results_map_filter( $query_args, $sfid ) { //if search form ID = 1530, the do something with this query if($sfid==1530) { //modify $query_args here before returning it $query_args['posts_per_page'] = -1; } return $query_args; } add_filter( 'sf_edit_query_args', 'results_map_filter', 10, 20 );
Thanks
Ross Moderator(Private) April 20, 2016 at 1:08 am #43325Just seen this – sorry for the delay – this should go in your functions.php file
-
AuthorPosts