多语言展示
当前在线:153今日阅读:176今日分享:34

自定义页面中获取wordpress的文章

自定义页面中获取wordpress中添加的最新文章
工具/原料

wordpress

方法/步骤
1

引用wp-blog-header.php文件,如wordpress放到blog目录中,需要加入目录信息,如下require('blog/wp-blog-header.php');

2

使用get_posts获取数据//定义一个数组,存储设置信息$args = array( 'numberposts' => 10, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");依次为,数量=10,发布的文章,提取post类型(wordpress有很多类型),按日期排序。//使用get_posts获取数据 $postslist = get_posts($args);

3

获取数据库,显示数据

the_permalink() 文章的永久链接the_title()  文章标题the_excerpt()  文章内容的简述

推荐信息