Function Reference/paginate comments links

来自WordPress中文文档
Zhuozuran讨论 | 贡献2009年3月14日 (六) 09:23的版本 (1个修订)
跳转至: 导航搜索

In version 2.7 WordPress added the Enhanced Comment Display system to make comments.php files much simpler to write and edit. One is the ability to easily break comments into pages so that you dont' 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.

paginate_comments_links($args);

It accepts a query-style list of arguments similar to codeget_posts()/code or codeget_terms()/code. Here are the defaults:

  • 'base' = add_query_arg( 'cpage', '%#%' ),
  • 'format' = ,
  • 'total' = $max_page,
  • 'current' = $page,
  • 'echo' = true,
  • 'add_fragment' = '#comments'

These arguments are mostly to make it work though, so be careful if you change them.

If you want more control, you can also use the simpler next and previous functions:

next_comments_link($label=, $max_page = 0)

and

previous_comments_link($label=)