网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

自定义页面中获取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() 文章内容的简述

© 2025 一点资料
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com