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

I'm building a custom homepage that has that structure:Cat 1Post 1 | Post 2 | Post 3Cat 1Post 1 | Post 2 | Post

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745315705a4622208.html

相关推荐

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

    I'm building a custom homepage that has that structure:Cat 1Post 1 | Post 2 | Post 3Cat 1Post 1 | Post 2 | Post

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信