define('WP_USE_THEMES', false); //无需使用主题
include_once('./wp-load.php'); //根据wordpress路径来调用 需要同服务器下
function get_posts_DESC($number){//获取$number条最新文章
$args = array(
'numberposts'=>$number,
'offset'=>0,
'category'=>"",
'orderby'=>'post_date',
'order'=>'DESC',
'include'=>"",
'exclude'=>"",
'meta_key'=>"",
'meta_value'=>"",
'post_type'=>'post',
'post_mime_type'=>"",
'post_parent'=>"",
'post_status'=>'publish'
);
$posts_array = get_posts($args);
$postnum=count($posts_array);
return $posts_array;
}
function get_posts_ASC($number){//获取$number条最老文章
$args = array(
'numberposts'=>$number,
'offset'=>0,
'category'=>"",
'orderby'=>'post_date',
'order'=>'ASC',
'include'=>"",
'exclude'=>"",
'meta_key'=>"",
'meta_value'=>"",
'post_type'=>'post',
'post_mime_type'=>"",
'post_parent'=>"",
'post_status'=>'publish'
);
$posts_array = get_posts($args);
$postnum=count($posts_array);
//$posts_array[$x]->post_title;//文章标题
return $posts_array;
}wordpress 获取指定数量的文章信息
文章版权及转载声明
作者:温文曦本文地址:https://wxnotes.com/blog/595.html发布于 2021-07-02
文章转载或复制请以超链接形式并注明出处文曦博客

还没有评论,来说两句吧...