Recently, I was having a conversation with a fellow developer via email about maintaining a separation of concerns in custom WordPress queries and WordPress templates.
The gist of the conversation boiled down to this:
Is it a good idea to keep custom queries in the template files?
A couple of years ago, I would’ve said yes but as I’ve begun to work on more complex projects, I’ve changed my mind: I’m actually a fan of keeping custom queries in functions.php
.
I think that this keeps code more maintainable, cleaner, and easier to read, though I’m not sure if this is the most common practice.