• I am modifying the search page to filter search results by posts and by pages. I have two while loops running in separate containers and an if( get_post_type() == ‘post’ ) or if( get_post_type() == ‘page’ ) to pull those results.

    The function works but now I have to limit the results to show only 3. How do I go about with this?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The search query, which presumably uses the WP_Query class, could be modified to include a “posts_per_page” query var set to any value you like. This will override the default posts per page setting used on other post listing pages.

    How to set this query var partly depends on how the search query is initiated. It can be done through the “pre_get_posts” action if the proper query can be distinguished from all others using conditional code.

Viewing 1 replies (of 1 total)
  • The topic ‘Search function to display certain number of results’ is closed to new replies.