首页 WordPress函数 WordPress获取最早或最近文章函数:get_boundary_post
正文 评论

WordPress获取最早或最近文章函数:get_boundary_post

WordPress函数get_boundary_post用于获取最早或最近发表的一篇文章,在实际应用中使用得非常少。

get_boundary_post( boolean $in_same_term = false, string $excluded_terms = \'\', boolean $start = true, string $taxonomy = \'category\' )

函数参数

$in_same_cat

布尔值,默认值:false

是否返回同分类下的文章,默认不区分分类。

$excluded_categories

字符串值,默认为空

提供排除分类的ID,多个ID用半角逗号分隔。

$start

布尔值,默认值:true

  • true:返回最早的文章;
  • false:返回最近的文章;

$taxonomy

字符串值,默认值:category

提供自定义分类法的名称

函数返回值

Array ([0] => WP_Post Object ([ID] => 36[post_author] => 1[post_date] => 2014-07-06 16:45:17[post_date_gmt] => 2014-07-06 08:45:17[post_content] => 文章内容[post_title] => 文章标题[post_excerpt] => 文章摘要[post_status] => publish[comment_status] => open[ping_status] => closed[post_password] =>[post_name] => 文章别名[to_ping] =>[pinged] =>[post_modified] => 2015-06-26 19:59:04[post_modified_gmt] => 2015-06-26 11:59:04[post_content_filtered] =>[post_parent] => 0[guid] => http://localhost/36.html[menu_order] => 0[post_type] => post[post_mime_type] =>[comment_count] => 0[filter] => raw ))

函数使用示例

<?php$first= get_boundary_post();if (!empty($first)) {foreach ($first as $post) {echo \'<a href=\"\' . get_permalink($post->ID) . \'\">\' . $post->post_title . \'</a>\';}}?>

扩展阅读

get_boundary_post()函数位于:wp-includes/link-template.php

相关函数:

  • get_next_post()
  • get_previous_post()
-=||=-收藏赞 (0)
更多主题
单栏极简文艺WordPress博客主题:Diaspora主题
¥ 0 关注:21,681
详情
v1.0.0
小程序收录免费WordPress主题:XCX主题
¥ 0 关注:21,681
详情
简约黑白WordPress个人博客主题:Personal主题
¥ 0 关注:21,314
详情
v1.0.0
一款简约单栏的免费WordPress博客主题:itheme主题
¥ 0 关注:19,265
详情
功能丰富切轻量的WordPress虚拟资源主题:Rizhuti主题
¥ 599 关注:19,240
详情
v3.4.0
适用自媒体资讯的免费WordPress主题:Autumn主题
¥ 0 关注:16,484
详情
回复
暂无评论

不要再留垃圾评论了,主题君整理资源不容易,留几句鼓励的话吧。