I know this is a very general question, but I have been reading tuts on both wp Query, and The Loop, and it seems that you can go either way. Am I misunderstanding this? What I think I am reading is that you can bypass the loop more or less, and just query the db. If this is the case, what is better?
|
There is no absolute better/worse/best/worst implementation. The correct implementation depends on what you're trying to accomplish. For a great explanation, I direct you to this post by Digging Into WordPress, which explains the 4 basic means of interacting with the WordPress Loop:
Give that post a read; it will help you understand when/how to use each option. EDIT p.s. more from Digging Into WordPress: if you use one of these methods to modify the query, you will want to familiarize yourself with when/how to reset the query. |
||||
|
|
Another thought to bear in mind: If there is ever to be the possibility that you may want to allow others to integrate with your code eg; to make mods without modifying the source, then chose a method where there are already wp filters, so that others may add filters to your code (eg to select only certain categories, or apply meta query selection etc) Querying the database directly with your own select call for example would NOT offer these possibilities. Sometimes it is hard to image what people may want to do, but allowing for the integration can make your plugin/theme very powerful. |
|||
|
|