#10867 closed enhancement (fixed)
next_post_link() and previous_post_link() should be allowed in the loop, even if is_single()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | low |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
I'm building a custom theme where the front page (example.org) is essentially an exact duplicate of a single post (example.org/2009/09/post-title/). Imagine my confusion when I copied the contents of single.php over to index.php and finding that the navigation links had disappeared.
I promptly tracked down the culprit, and it turned out to be a requirement in get_adjacent_post: if !is_single, it returns null.
I see no reason as to why these links should not be allowed everywhere in the loop. The codex page even states it is allowed in the loop, not telling of the extra limitations. Unless there is some reason of which I am not aware, I suggest that the attached patch be applied.
Attachments (2)
Change History (12)
#2
@
15 years ago
- Keywords 2nd-opinion added; themes the-loop removed
- Milestone changed from Unassigned to 3.0
it could be argued they could be used for attachments, too (i.e. next gallery image)
#3
@
15 years ago
I agree we should remove the !is_single() and is_attachment() checks, but could this potentially suddenly have links show up in themes?
#4
@
15 years ago
Agree on removing is_attachment() too.
Yeah, links might pop up in 0.01% of themes, but I doubt there would be a backlash over the issue.
#6
@
15 years ago
- Resolution fixed deleted
- Severity changed from trivial to normal
- Status changed from closed to reopened
There are several themes (Journalist, Garland, presumably many others) that use previous_post_link()/next_post_link() on index.php without wrapping them in is_singular() conditionals.
Prior to 3.0, the links would not show unless the current page was is_singular(). Now they show up on all pages including the front page.
I like the 3.0 versions better (more flexible), but they break some themes.
Reopening.
Could leave as is.
Could revert.
Could add a new argument (or convert it them to wp_parse_args() based functions).
Could ...?
#7
@
15 years ago
This also causes two pointless queries for every page because adjacent_posts_rel_link() is hooked to wp_head. Attached patch solves that given the current code.
#9
@
15 years ago
- Resolution set to fixed
- Status changed from reopened to closed
MarkJaquith, nacin, ryan and I chatted about this OOB. We looked through themes in http://themes.svn.wordpress.org/ and decided that while this change breaks back compat, it doesn't affect too many themes. Most are either already wrapping in is_singular() conditionals or using them in single.php only.
We decided the back compat problems are worth the additional flexibility.
I guess we should sent something out to theme devs about this?
patch