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

 时间:2024-11-23 17:08:30

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、获取数据库,显示数据<ul><li><a href='<?php the_permalink(); ?>' title='<?php the_title() ?>' target='_blank'><strong><?php the_title() ?></strong></a><?php the_excerpt(); ?></li></ul>the_permalink() 文章的永久链接the_title() 文章标题the_excerpt() 文章内容的简述

  • wordpress如何添加自定义页面模板
  • 如何在WordPress中编辑自定义页面
  • wordpress怎么自定义url
  • wordpress如何发布文章?
  • WordPress如何自定义友情链接
  • 热门搜索
    泥鳅汤的做法 柚子茶的做法 家常炖排骨的做法 烫伤起泡怎么处理 腌鸡蛋的做法大全家常 荆怎么读 平仄怎么分 冬瓜羊肉汤的做法 孜然牛肉的家常做法 煮鸡蛋的做法