Opened 18 years ago
Closed 18 years ago
#8168 closed defect (bug) (fixed)
Using "type" parameter on wp_list_comments() screws up paging
| Reported by: | Viper007Bond | Owned by: | Viper007Bond |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.7 |
| Component: | Comments | Version: | 2.7 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
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.
Solution:
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.
Attachments (1)
Change History (8)
#2
@
18 years ago
- Milestone 2.8 → 2.7
8168.patch should make paging work properly if you pass a type parameter or a $comments to wp_list_comments().
However, doing either of the aforementioned things will break get_comment_link() if used outside of the comment loop as the $page parameter is not passed to it and it therefore gets the page number wrong (due to "missing" comments).
#3
@
18 years ago
Oh, and get_comment_link() will also break on custom themes using a callback function if they forget to pass $page to it as well.
#4
@
18 years ago
This is probably along the same lines if not I'll open a new ticket, but the comment_reply_link function doesn't work either when it's used in a callback. I've applied the patch to see if it would help but it doesn't. I'm also not exactly sure how to pass the $page to this function either.
#5
@
18 years ago
<?php echo get_comment_link( $comment->comment_ID, $args['page'] ); ?>
Might be worth making it automatic via a global or something.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Forgot to actually mention that I'm not done with the patch yet, but I thought I'd open the ticket to make people aware of the issues and that I'm working on the patch.
Hoping to get this into 2.7.