paginate_comments_links()
paginate_comments_links( string|array $args = array() )…
paginate_comments_links( string|array $args = array() )
显示或检索当前文章评论的分页链接。
Displays or retrieves pagination links for the comments on the current post.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
另见函数 paginate_links()
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $args | (string | array) | 可选 | 阿尔格斯。请参见分页链接()。 |
返回(Return)
(void|string|array)如果“echo”参数为true且“type”不是数组,或者如果查询不是针对任何post类型的现有单个post,则为void。否则,根据“type”参数,标记注释页链接或注释页链接数组。
源码(Source)
/**
* Create pagination links for the comments on the current post.
*
* @see paginate_links()
* @since 2.7.0
*
* @global WP_Rewrite $wp_rewrite
*
* @param string|array $args Optional args. See paginate_links().
* @return string|void Markup for pagination links.
*/
function paginate_comments_links($args = array()) {
global $wp_rewrite;
if ( !is_singular() || !get_option('page_comments') )
return;
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
$max_page = get_comment_pages_count();
$defaults = array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'total' => $max_page,
'current' => $page,
'echo' => true,
'add_fragment' => '#comments'
);
if ( $wp_rewrite->using_permalinks() )
$defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
$args = wp_parse_args( $args, $defaults );
$page_links = paginate_links( $args );
if ( $args['echo'] )
echo $page_links;
else
return $page_links;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.7.0 | wp-includes/link-template.php:2978 | 1 function | 10 |
笔记(Notes)
增强的注释显示
自定义上一个/下一个链接
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!