我正在使用以下代码查询数据库,它工作正常
<?php query_posts(
'post_type=gallery&posts_per_page='.$gnum.'&paged='.$paged.'&orderby=title&order=ASC'
); ?>
您能否告诉我如何在上述查询中添加 WHERE NOT。
( WHERE ID != '400' AND ID!='401'
)
在 wordpress 查询后添加参数post__not_in
。
'post__not_in' => array(400, 401)
$args = array(
'post_type' => 'gallery',
'posts_per_page' => $gnum,
'post__not_in' => array(400, 401),
'paged' => $paged,
'orderby' => 'title',
'order' => 'ASC'
);
所以你的查询帖子会像,
query_posts($args);
试试这个...
$args = array(
'post_type' => 'gallery',
'posts_per_page' => $gnum,
'paged' => $paged,
'orderby' => 'title',
'order' => 'ASC',
'post__not_in' => array(6,2,8)
);
query_posts( $args );
<?php query_posts(
'post_type=gallery&posts_per_page='.$gnum.'&paged='.$paged.'&orderby=title&ID='-400,-401'&order=ASC'
); ?>