首页 > 解决方案 > 如何在 WordPress 上获取帖子列表(仅标题、日期和时间)

问题描述

请问如何获得帖子标题,我想在一页中列出 20 个帖子,并且会有下一个按钮,请帮助我

标签: wordpresswordpress-themingcustom-wordpress-pages

解决方案


<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
  'posts_per_page' => 20 // Number of Post you Want in a page
  'paged' => $paged // Tells the current number of page in query
);
$my_query = new WP_Query( $args ); // adding custom query

   while($custom_query->have_posts()) :
      $custom_query->the_post();
 the_title(); // Getting and printing the title of POST/Page

        endwhile; 
       if (function_exists("pagination")) {
          pagination($my_query->max_num_pages); // Calling pagination 
      } ?>

推荐阅读