start_post_rel_link()
云策文档标注
概述
start_post_rel_link() 是一个已弃用的 WordPress 函数,用于显示第一篇相关文章的链接。它已被 get_boundary_post_rel_link() 替代,自 3.3.0 版本起不建议使用。
关键要点
- 函数已弃用:自 WordPress 3.3.0 起,start_post_rel_link() 被标记为弃用,应改用 get_boundary_post_rel_link()。
- 功能作用:显示第一篇相关文章的链接,支持自定义标题格式、是否在同一分类和排除分类等参数。
- 参数说明:包括 $title(标题格式)、$in_same_cat(是否在同一分类)、$excluded_categories(排除分类 ID)。
- 相关函数:与 get_boundary_post_rel_link() 和 _deprecated_function() 关联,用于处理边界文章链接和弃用通知。
代码示例
function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
_deprecated_function( __FUNCTION__, '3.3.0' );
echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
}注意事项
- 弃用警告:使用此函数会触发 _deprecated_function() 警告,建议在开发中避免使用,以保持代码兼容性和最佳实践。
- 替代方案:直接调用 get_boundary_post_rel_link() 并设置参数来获取第一篇相关文章链接。
原文内容
Display relational link for the first post.
Parameters
$titlestringoptional-
Link title format.
$in_same_catbooloptional-
Whether link should be in a same category.
Default:
false $excluded_categoriesstringoptional-
Excluded categories IDs.
Source
function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
_deprecated_function( __FUNCTION__, '3.3.0' );
echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
}