paginate_comments_links( string|array $args = array() )
Displays or retrieves pagination links for the comments on the current post.
Contents
Description Description
See also See also
Parameters Parameters
- $args
-
(string|array) (Optional) args. See paginate_links().
Default value: array()
Return Return
(string|array|void) Markup for comment page links or array of comment page links.
Source Source
File: wp-includes/link-template.php
function paginate_comments_links( $args = array() ) { global $wp_rewrite; if ( ! is_singular() ) { 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, 'type' => 'plain', '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'] && 'array' !== $args['type'] ) { echo $page_links; } else { return $page_links; } }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Enhanced Comment Display
WordPress makes comments.php files simple to write and edit. It’s simple to easily break comments into pages so that you don’t end up with hundreds of comments all loading on every pageview.
You will need to set up the options in SETTINGS > DISCUSSION for paging to work.
The easiest way to do so is with the following function, which prints out a link to the next and previous comment pages, as well as a numbered list of all the comment pages.
It accepts an array or query-style list of arguments similar to get_posts() or get_terms().
If you want more control, you can also use the simpler next and previous functions:
and
Custom Prev-/Next-links
To modify the Prev- and Next-links, you can use the options ‘prev_text’ and ‘next_text’. These are provided by the function paginate_links().
Note: If you want to use HTML entities in your ‘prev_text’ or ‘next_text’, you will have to use the array-based syntax.