Timeline for Show a different number of posts per page depending on context (e.g., homepage, search, archive)
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 8, 2011 at 16:24 | comment | added | Doug | Actually I misread your second-to-last paragraph and thought the "larger" and "smaller" lists of posts were on the same page, so my last sentence above was irrelevant. And yes, it's perfectly legitimate to put all your code in index.php if you want. And if that's the case, then your method is a quick and easy way to do this, so I'll remove my downvote after the 20 hour lock is over. Even so, sending a new query rather than modifying the original query as in kevtrout's answer is less desirable for the reasons already mentioned (by you, me and the WP Codex). | |
Jul 7, 2011 at 21:51 | comment | added | Jeff Atwood | @doug this isn't a secondary loop, it's overriding the main loop -- and yes, this particular theme uses index.php to render everything, it's fairly minimalistic. I felt this made more sense here as an answer, but if you'd like I can ask my own question and answer it if this answer offends you in some way. | |
Jul 7, 2011 at 19:26 | comment | added | Doug | Jeff, I was looking for a centralized place to control the number of posts returned in different contexts. Your answer only does that if you use index.php to handle ALL contexts, which most themes don't do. In addition to increasing the calls to the database (which affects performance), your technique can also change the response to conditional tags (e.g., is_home() or is_front_page) in unexpected ways. Finally, if you're wanting to add secondary loops to a page, you should NOT use query_posts, but use "new WP_Query" instead (or get_posts). | |
Jul 6, 2011 at 23:35 | history | edited | Jeff Atwood | CC BY-SA 3.0 |
added 128 characters in body
|
Jul 6, 2011 at 23:25 | history | answered | Jeff Atwood | CC BY-SA 3.0 |