1

In my template files I have a lot of WP_Query to get posts of an author or from a specif category ecc... I'm thinking to use Repository Patter in order to have cleaner code and a layer between database and theme.

This PostRepository class will have some methods like: - getByID - getByAuthor - getByCategory

Could be a good idea? Have somebody use somethink like this?

1 Answer 1

0

Yes absolutely, It would be great to abstract away your queries at a single place. You might also use caching in your repository.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.