previous_post

函数
previous_post ( $format = '%', $previous = 'previous post: ', $title = 'yes', $in_same_cat = 'no', $limitprev = 1, $excluded_categories = '' )
参数
  • (string) $format
    Required:
    Default: '%'
  • (string) $previous
    Required:
    Default: 'previous post: '
  • (string) $title
    Required:
    Default: 'yes'
  • (string) $in_same_cat
    Required:
    Default: 'no'
  • (int) $limitprev
    Required:
    Default: 1
  • (string) $excluded_categories
    Required:
    Default: (empty)
相关
  • previous_post_link()
定义位置
相关方法
previous_postsget_previous_postprevious_post_linkprevious_posts_linkget_previous_post_link
引入
1.5.0
弃用
2.0.0

previous_post: 这个函数检索在同一类别或分类法中,在当前文章之前发表的前一个文章。它可以用来显示前一篇文章的链接。

打印指向前一篇文章的链接。

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;
}

常见问题

FAQs
查看更多 >