previous_post() - WordPress 函数参考中文文档

返回介绍

previous_post()

发布于 2017-09-11 字数2554 浏览 792 评论 0

Warning: This function has been deprecated. Use previous_post_link() instead.

previous_post( string $format = '%',  string $previous = 'previous post: ',  string $title = 'yes',  string $in_same_cat = 'no',  int $limitprev = 1,  string $excluded_categories = '' )

Prints a link to the previous post.


描述


参数

$format

(string)
(Optional)

Default value: ‘%’

$previous

(string)
(Optional)

Default value: ‘previous post: ‘

$title

(string)
(Optional)

Default value: ‘yes’

$in_same_cat

(string)
(Optional)

Default value: ‘no’

$limitprev

(int)
(Optional)

Default value: 1

$excluded_categories

(string)
(Optional)

Default value: ”


源代码

File: wp-includes/deprecated.php

function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {

	_deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' );

	if ( empty($in_same_cat) || 'no' == $in_same_cat )
		$in_same_cat = false;
	else
		$in_same_cat = true;

	$post = get_previous_post($in_same_cat, $excluded_categories);

	if ( !$post )
		return;

	$string = '<a href="'.get_permalink($post->ID).'">'.$previous;
	if ( 'yes' == $title )
		$string .= apply_filters('the_title', $post->post_title, $post->ID);
	$string .= '</a>';
	$format = str_replace('%', $string, $format);
	echo $format;
}

更新日志

Version 描述
2.0.0 Use previous_post_link()
1.5.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/link-template.php:
    get_previous_post()
  • wp-includes/link-template.php:
    get_permalink()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/post-template.php:
    the_title

User Contributed Notes

上一篇:previous_image_link()

下一篇:previous_posts()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!