最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - Get all top categories, then only 3 posts for each

programmeradmin1浏览0评论

I'm building a custom homepage that has that structure:

 Cat 1

Post 1 | Post 2 | Post 3

Cat 1

Post 1 | Post 2 | Post 3

etc...

I know how to get all top non-empty categories, loop through them and inside each fetch latest 3 posts. However, that would imply doing as many exdtra DB queries as categories I have, so I think that would not be optimal.

I think I might be able to hack a custom SQL query that fetches that data only, but I want to be able to use recular post code such as <?php the_permalink(); ?>.

Is there an optimal solution to this?

发布评论

评论列表(0)

  1. 暂无评论