以下是我的wordpress查询,其中我只想显示粘贴的帖子,但查询没有显示任何帖子.另外我将两个帖子设置为粘性,以便检查部分!!! 请告诉我如何修改此查询,以便它只显示粘贴的帖子
<?php
$wp_query = null;
$wp_query = new WP_Query(array(
'posts_per_page' => 2,
//'paged' => get_query_var('paged'),
'post_type' => 'post',
'post__in' => 'sticky_posts',
//'post__not_in' => array($lastpost),
'post_status' => 'publish',
'caller_get_posts'=> 0 ));
while ($wp_query->have_posts()) : $wp_query->the_post(); $lastpost[] = get_the_ID();
?>
Run Code Online (Sandbox Code Playgroud)
小智 10
查询仅显示粘贴帖子:
// get sticky posts from DB
$sticky = get_option('sticky_posts');
// check if there are any
if (!empty($sticky)) {
// optional: sort the newest IDs first
rsort($sticky);
// override the query
$args = array(
'post__in' => $sticky
);
query_posts($args);
// the loop
while (have_posts()) {
the_post();
// your code
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9736 次 |
| 最近记录: |