如何在一个URL上显示多篇文章和文章内容。像这样https://www.recruitment.guru/ssc/ssc-recruitment/在单个帖子页面上显示帖子。
请提出解决方案。
如何在一个URL上显示多篇文章和文章内容。像这样https://www.recruitment.guru/ssc/ssc-recruitment/在单个帖子页面上显示帖子。
请提出解决方案。
首先,您需要创建custom page template 并从页面复制样式。php文件。之后,您将使用下面的循环在一个页面中显示所有帖子###
<?php
// the query
$wpb_all_query = new WP_Query(array(\'post_type\'=>\'post\', \'post_status\'=>\'publish\', \'posts_per_page\'=>-1)); ?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<ul>
<!-- the loop -->
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<!-- end of the loop -->
</ul>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
我试了很多次,但没有得到正确的结果。有人请检查我的代码,我哪里做错了。我想显示具有相同类别的其他帖子,但不是单个页面上显示的帖子,而是当前帖子的上一篇和下一篇帖子。有没有其他方式可以展示?$thisid = get_the_ID(); $prevpost = get_previous_post(); $previd = $prevpost->ID; $nextpost = get_next_post(); $nextid = $nextpost->ID;