外贸独立站的底层设计密码WordPress 成品站模板
当前位置:首页>WordPress建站>WordPress开发>WordPress函数:get_adjacent_post(获取相邻文章)

WordPress函数:get_adjacent_post(获取相邻文章)

Description【描述】

Retrieve adjacent post.【检索相邻的文章】

Can either be next or previous post.【可以是上一篇或下一篇】

Usage【用法】

<?php get_adjacent_post( $in_same_cat, $excluded_categories, $previous ) ?> 

Parameters【参数】

$in_same_cat
(boolean) (optional) Whether post should be in same category.【(布尔值)(可选)文章是否在同一分类】

Default: false【默认:false】
$excluded_categories
(string) (optional) Excluded categories IDs.【(字符串)(可选)排除分类的ID】

Default: ”【默认:”】
$previous
(boolean) (optional) Whether to retrieve previous post.【(布尔值)(可选)是否检索之前的文章】

Default: true【默认:true】

Return Values【返回值】

  • Post object if successful. 【如果成功,返回文章对象】
  • Null if global $post is not set. 【如果全局的 $post 没有设置,返回空值】
  • Empty string if no corresponding post exists. 【如果不存在符合条件的文章,返回空字符串】

Examples【例子】

Notes【注释】

  • Uses global: (object) $post 【使用全局:(对象)$post
  • Uses global: (object) $wpdb 【使用全局:(对象)$wpdb

Filters【过滤器】

$adjacent is either ‘previous’ or ‘next’.【$adjacent 是“上一篇”或“下一篇”】

  • "get_{$adjacent}_post_join":

    $join, $in_same_cat, $excluded_categories

  • "get_{$adjacent}_post_where":

    $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories

  • "get_{$adjacent}_post_sort":

    "ORDER BY p.post_date $order LIMIT 1"

Change Log【更改记录】

Since: 2.5.0 【从 2.5.0 开始】

Source File【源文件】

get_adjacent_post() is located in wp-includes/link-template.php.【get_adjacent_post()函数在wp-includes/link-template.php 文件中】

参考资料:http://codex.wordpress.org/Function_Reference/get_adjacent_post

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
欢迎关注WordPress大学公众号 WPDAXUE
WordPress开发

WordPress函数:get_extended(获取扩展信息)

2013-3-19 20:40:00

WordPress开发

WordPress函数:get_boundary_post(获取边界文章)

2013-3-21 6:54:00

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索