wordpress 获取指定数量的文章信息

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;
}
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;
}
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; }
© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
More grow up more lonely, more grow up more uneasy.
越长大越孤单 ,越长大越不安
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容