[wp-trac] [WordPress Trac] #24142: Zero value for posts_per_page value in wp_query custom instance and for 'Blog pages show at most' option

WordPress Trac noreply at wordpress.org
Thu May 13 14:46:28 UTC 2021


#24142: Zero value for posts_per_page value in wp_query custom instance and for
'Blog pages show at most' option
--------------------------------------------+-----------------------------
 Reporter:  alexvorn2                       |       Owner:  SergeyBiryukov
     Type:  defect (bug)                    |      Status:  reviewing
 Priority:  normal                          |   Milestone:  Future Release
Component:  Query                           |     Version:
 Severity:  normal                          |  Resolution:
 Keywords:  needs-unit-tests needs-testing  |     Focuses:
--------------------------------------------+-----------------------------

Comment (by molinerozadkiel):

 use case for "posts_per_page" => 0 to display no posts:

 I am building a ajax search bar in a header, I have all the logic already
 done and working from older projects, but in this case the designer had
 the brilliant idea to show no posts if the search bar is empty (because
 the results are shown within the header, so is good to now show anything
 if the user is not looking for something so that is won't produce visual
 clutter)
 So, I would like to jus be able to pass a 0 there when the search bar is
 empty...

 Besides, "0 to show 0 posts" makes sense, and not doing it like this makes
 the system more prone to errors and harder to debug, as stated by other
 users before.
 0 counts as "False" in many cases so I imagine the problem is problbly
 comming from there somehow

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24142#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list