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

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19365
    themagnificothemagnifico
    Participant

    Hi,
    first of all thank You very much for this fantastic plugin.

    I would like to display 10 results taken from movie CPT and then from normal posts.

    I need to have max 3 results from the movie CPT and then from the normal posts (if possible up to 10… so they could 7 results)

    I have already set:
    in the General Options > Ordering: first Movie CPT, then Posts
    in the General Options > Limits: 10

    I understand that if i activate the “Distribute the posts limit between each post type equally” i would obtain 5 Movie posts and 5 regular posts

    But i need at maximum 3 movies and then all the available posts (up to 10 as set in the limit)

    Could You please tell me if it is possible to obtain this kind of result?

    Thanks in advance

    Luca M.

    #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.

    #19378
    themagnificothemagnifico
    Participant

    Awesome!
    Thanks a lot

    Luca

    #19379
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #19381
    themagnificothemagnifico
    Participant

    You cannot access this content.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Limit the number of the first displayed CPT posts’ is closed to new replies.