Timeline for Get all categories and posts in those categories
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 29, 2018 at 17:47 | comment | added | S.. | O(n) inefficient | |
| Jan 6, 2015 at 8:12 | history | edited | Pieter Goosen | CC BY-SA 3.0 | deleted 14 characters in body |
| Nov 29, 2013 at 11:57 | history | edited | Krzysiek Dróżdż | CC BY-SA 3.0 | Reformatted code |
| Feb 25, 2012 at 1:21 | comment | added | Sagive | hmm.. dont know - dont understand it to this extent.. i mean the way wordpress acts on this query.. but. i tried and i think it work really fast. i hope i at least shortend the way to your desired solution. ;) | |
| Feb 25, 2012 at 1:11 | comment | added | Ben | The difference is the number of db queries. One big vs. many small... ;) | |
| Feb 25, 2012 at 0:37 | comment | added | Sagive | i think it would we asking the database the same question but just ordering stuff differently on the output end.. i dont see the difference... besides - its a logical query.. "give me the first * from this category"... give me the first * from that category" instead of give me that post, again, again, again.. its the same way but i am puling the data in the way i need it... unless i am mistaken.. | |
| Feb 25, 2012 at 0:04 | comment | added | Ben | No it doesn't, you just need to change the output slightly (i.e. end list for cat n, and start list for cat n+1) everytime a post has a category that is different from the previous post's category... A lot simpler than bombarding your poor database with 20+ queries per pageload... (to my humble opinion :) | |
| Feb 24, 2012 at 23:33 | comment | added | Sagive | i dont think it matters one bit if its 10 categories or 20... (tried it with 20) unless you are trying to load a huge number posts which in any case might slow the page load.. try it - you'll find it real breezy - trying to rearrange after loaded via categories would mean building a huge and mostly useless code (to my humble opinion :) ) | |
| Feb 24, 2012 at 23:12 | comment | added | Ben | Thx, but take the example of say 10 categories. In that case your code causes 11 SQL queries. I am looking for 1 SQL query. The best thing would probably be to get all posts, ordered by category, but I don't know how to do that (I didn't find order_by = cat in the codex) !? | |
| Feb 24, 2012 at 22:39 | history | edited | Sagive | CC BY-SA 3.0 | imporved formating |
| Feb 24, 2012 at 22:30 | history | answered | Sagive | CC BY-SA 3.0 |