Using "type" parameter on wp_list_comments() screws up paging
|Reported by:||Viper007Bond||Owned by:||Viper007Bond|
Who It Affects:
Those who use comment paging and either set the type parameter on wp_list_comments() or pass a custom $comments to that function.
Everyone else (for example, the default theme) is unaffected.
What Happens And Why:
If you have the latest/newest comments page set to show by default, it can show up as blank. For example, if you have 22 comments (2 of which are pings), 5 comments per page, and do wp_list_comments( array( 'type' => 'comment' ) ), you'd end up with 4 pages and the 5th page (which should no longer exist) being blank. get_comment_pages_count() is at fault here as it's using the wrong total comments number when diving total comments by comments per page. If you have the oldest page set as the default, next/previous_comments_link() is smart enough (apparently) to not continue on to the next page.
get_comment_link() also ends up using the wrong page number as it's expecting comments to be displayed that aren't. get_page_of_comment() is at fault here as it's SQL query is grabbing comments that we've excluded.
I spent an hour or two on this last night. Basically what I've been doing is passing along $args to the other various functions. This way they can realize what's going on and account for it.