change the posts_per_page argument in WP Query

Forums › Forums › Search & Filter Pro › change the posts_per_page argument in WP Query

Viewing 9 posts – 1 through 9 (of 9 total)
  • Anonymous
    #120695

    Hi,

    I was wondering if it’s possible to alter the WP query arguments of the search filter.
    You see I add the search filter arguments to the general arguments;

    
    $args['search_filter_id'] = 71;
    

    Which works perfectly. But these arguments have ‘posts_per_page => 9’. This display correctly.
    See:
    http://wbr.ikon.be/te-huur/
    I also have a tab with a Google map that I would like to display all the results (not just 9 as is now the case; click the ‘Kaart’ tab on: http://wbr.ikon.be/te-huur/

    So for that I would need to alter the arguments of $args['search_filter_id'] = 71; by changing posts per page to => -1. I was wondering if this is somehow possible?
    Setting the regular argument to 'posts_per_page' => -1 doesn’t work because $args['search_filter_id'] = 71; overrides it.

    Thanks in advance!

    Anonymous
    #120696

    Again I forgot ‘follow-up via email’ so I’m checking it here.

    Trevor
    #120702

    I guess you would need to use is_page() to detect which page you are on and make two forms for filtering, identical except for the number of posts.

    Anonymous
    #120734

    Thanks for the quick reply.
    But that would mean two different search forms. (one with posts_per_page = 9 and one with -1).
    But the search is done on the homepage and the results displayed on the ‘te-huur’ page. I just need those same results for two different ‘tabs’ so the same results with ‘9’ and ‘-1’, but for that i need to alter the search form argument that sets it to ‘9’. If that is possible.

    Anonymous
    #120736
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array(
    		'order'=> 'ASC',
    		'orderby' => 'date',
    		'post_type' => 'panden', 
    		'posts_per_page' => 9,
    		'meta_key' => 'status',
    		'meta_value' => array('Te huur', 'Te huur onder reservatie'),
    	'paged' => $paged);
    	$args['search_filter_id'] = 71;
    	$pandenLoop = new WP_Query($args);
    

    I thought I would create a new WP_Query with those same arguments and just alter the ”posts_per_page’ => 9,’. But these are set in ‘$args[‘search_filter_id’] = 71;’ and I don’t know how to access those arguments.

    posts_per_page' => 9 has no effect here because it take that argument from $args['search_filter_id'] = 71;

    Trevor
    #120740

    I am not sure that we are understanding each other. Is a Skype voice session possible, so we can talk this thing through?

    Anonymous
    #120748
    This reply has been marked as private.
    Trevor
    #120750

    Yes, you can use get_field(). I have made many custom results.php templates for various ACF fields.

    Anonymous
    #120766
    This reply has been marked as private.
Viewing 9 posts – 1 through 9 (of 9 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.