开发者

Wordpress query, exclude latest post from a category

开发者 https://www.devze.com 2023-04-03 02:16 出处:网络
Is it possible to get posts from all categories but exlude only one latest post from specific categories.

Is it possible to get posts from all categories but exlude only one latest post from specific categories. Something like: get posts from all ca开发者_开发百科tegories, but exclude latest post from category 2,4 and 5. PS. I'm looking for wordpress query (not mysql), for example somethng like

<?php $my_query = new WP_Query('showposts=10'); ?>

Thanks.


How about this:

<?php $my_query = new WP_Query('showposts=10&offset=1'); ?>

Does that work for you?


In MySQL, I would suggest something like this:

SELECT * FROM posts WHERE id NOT IN 
    (SELECT id FROM posts WHERE category IN (2,4,5) ORDER BY id DESC LIMIT 0,1)
0

精彩评论

暂无评论...
验证码 换一张
取 消