Opened 11 years ago
Closed 11 years ago
#33211 closed defect (bug) (worksforme)
get_adjacent_post is not working with post_format
| Reported by: | valendesigns | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | needs-unit-tests |
| Cc: | Focuses: | template |
Description
When I was creating a custom post navigation function today for a client with WP 4.2.3, specifically for post formats, I noticed that the following does not return adjacent posts, even though they exist. I'm not sure if this has ever worked or is a regression. Has anyone been successful in using get_adjacent_post with post_format?
$prev = get_adjacent_post( true, '', true, 'post_format' ); $next = get_adjacent_post( true, '', false, 'post_format' );
Change History (5)
#2
follow-up:
↓ 3
@
11 years ago
Thank you for testing. Unfortunately, these post have non-standard formats. They are video, audio, & image formats with more than one in each term. None of them are finding adjacent posts for either previous or next. Could you briefly describe how you tested the issue?
#3
in reply to: ↑ 2
@
11 years ago
Replying to valendesigns:
Could you briefly describe how you tested the issue?
I've created two asides, added your snippet to single.php, and checked the values of $prev and $next.
$next contained Aside 2 when viewing Aside 1, and $prev contained Aside 1 when viewing Aside 2.
#4
@
11 years ago
- Keywords needs-patch removed
I guess I have to look deeper into this clients plugins and see if there's a conflict somewhere. Yay! At any rate we should have coverage here, the tests for get_adjacent_post are not covering all core taxonomies and they probably should be.
#5
@
11 years ago
- Milestone Awaiting Review
- Resolution → worksforme
- Status new → closed
I'll open a ticket for the unit tests later. I found the issue in my clients theme, which is an old one I didn't create and has loads of code. It seems to have a filter on get_previous_post_where & get_next_post_where that removes the post_format taxonomy from the query. I was able to bypass and everything it working correctly. I guess I should have dug deeper earlier. Thanks for verifying that it does work.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Just tested, and it only works for posts that actually have a format other than Standard (otherwise they're not connected to any term from the
post_formattaxonomy).