【发布时间】:2017-07-03 03:36:41
【问题描述】:
我在我的 wordpress 主题中使用了 wp_query。 我有重复的帖子我的主页。 这要怎么修?这个问题跟什么有关系?
整个悖论是,如果您将此代码用作单独的模板,那么一切正常。如果您将主题嵌入到模块中,那么所有帖子都会按顺序排列。然后是 (1,2,3,4,5,1,2,3,4,5)。
谢谢。
}
function render() {
ob_start();
?>
<?php $custom_query = new WP_Query('posts_per_page= 1');
while($custom_query->have_posts()) : $custom_query->the_post();
?>
<div class="post-1">
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h3>
<div class="float-tags">
<div class="bb-td-post-small-box clearfix">
<?php the_tags('','',''); ?>
</div>
</div>
<div class="post-2">
<?php the_content(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php return ob_get_clean();
}
}
【问题讨论】:
-
所以你的数据库中有重复的数据?
-
复制我的主页,看截图
-
能否请您发送您的管理仪表板 [帖子列表和页面列表] 部分的屏幕截图。
标签: wordpress