let's say I have posts with hundreds of comments, and that I want to show only the last N comments and then a link to a page read them all. How would I display the last N comments?
Thank you, Dino.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communitylet's say I have posts with hundreds of comments, and that I want to show only the last N comments and then a link to a page read them all. How would I display the last N comments?
Thank you, Dino.
See.
http://codex.wordpress.org/Function_Reference/get_comments
Set the orderby parameter to your desired value, possible values are.
comment_agent
comment_approved
comment_author
comment_author_email
comment_author_IP
comment_author_url
comment_content
comment_date
comment_date_gmt
comment_ID
comment_karma
comment_parent
comment_post_ID
comment_type
user_id
Refer to the link already provided for info on setting other parameters, and general examples.
comments_template()
with this, otherwise WP will still query the database for those hundreds of comments. To display all the comments on a separate page call the current page with a query argument like ?show_all_comments
. Get all the comments form the db if this argument is present, otherwise get only 10 or something like that
Dec 19, 2010 at 11:16
Why not just use native functionality for comment pagination?
See Enhanced Comment Display, Settings > Discussion in Codex.