我有一个小wordpress博客。博客中大约有50篇帖子。我想创建一个页面,该页面将登记所有帖子标题。我使用了“W4 Post List”wordpress插件,但这并不能解决我的问题。请向我推荐任何其他wordpress插件或代码。
列出特定页面中的所有帖子
1 个回复
最合适的回答,由SO网友:Kanon Chowdhury 整理而成
首先,创建一个自定义页面模板并粘贴代码
<?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; ?>
对于自定义页面模板,请访问this link 对于WP\\U查询访问this link