This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Limit the number of the first displayed CPT posts

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Limit the number of the first displayed CPT posts Reply To: Limit the number of the first displayed CPT posts

#19377
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Luca,

I had to revisit your question, as initially I was not able to find a solution. Turns out, the only way to achieve this is by making direct modifications to the code. The downside of direct modifications is, that it will be deleted on plugin updates.
I am not sure, if I can add a filter to the code in future releases to make a permanent solution, but I will try for sure.

In case you are interested in this solution, here it is:
1. Before starting, make sure to have a full site back-up just in case.
2. Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-query.php file on your server and find lines 634 – 635, which should be these:

[php]
$args[‘posts_limit’] = $_temp_ptype_limits[$_tptype][0];
$args[‘posts_limit_override’] = $_temp_ptype_limits[$_tptype][1];
[/php]

3. Change those lines to this:

4. Change the $_post_type to the post type name where you want to override the limit, also the $_limit variable for the number of items.
5. Save the file.
6. Make sure, that the post limit distribution is enabled, and is set to 14 in your case (because 14 total/2 post types = 7 item per post type max – might need to be increased a bit, I am not sure if the calculation will be correct once the found items are deducted).

I have not tested this solution in every possible way, so there is a very good chance, that it may not work in every case. Let’s hope it does the trick.