wordpress - 如何在 WordPress 上获取帖子列表(仅标题、日期和时间)
问题描述
请问如何获得帖子标题,我想在一页中列出 20 个帖子,并且会有下一个按钮,请帮助我
解决方案
<?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
} ?>
推荐阅读
- javascript - 将插入符号放在 ContentEditable Div 的末尾不起作用
- swift - 如何使用 Swift 4 以编程方式获取授权以将视频文件从应用程序目录复制到照片库
- c++ - 带分隔符的 C++ 文件读取
- c# - 只能在按下向下键时获得 Combobox selectedValue
- c# - 完成远程连接 SQL 数据库的步骤(通过 WIFI)
- excel - 根据单元格值显示形状
- android - 第一次工作后,在 onActivityResult 上为 android.media.action.IMAGE_CAPTURE 的活动提供结果失败
- telegram - 如何在 api 结果中确定是否从电报群聊中删除了一条消息?
- android - Geocoder 对象的地址错误
- char - 如何在opengge progress 4gl中创建启用垂直滚动条的多行文本字段?