#15883 closed defect (bug) (invalid)
when using get_posts() post_date does not get localized
Reported by: | bmb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.0.3 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
when getting a list of posts via the simple get_posts instead of the WP_query loop, the post_date field of each post is not formatted or localized or have any type of filter applied. I think it should pass through mysql2date, but have no idea where this should happen.
Change History (4)
#2
follow-up:
↓ 3
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#3
in reply to:
↑ 2
@
14 years ago
Replying to scribu:
Filters are applied only when you call template tags, like the_title(), the_date() etc.
So, the problem isn't that you're using get_posts(), but that you're accessing the post_date property directly instead of via get_the_date().
when using get_posts, I can't use get_the_date, since it doesn't set the global $post, but I had understood that this was the correct simple method for getting posts, not using WP_query and loops.
#4
@
14 years ago
when using get_posts, I can't use get_the_date, since it doesn't set the global $post, but I had understood that this was the correct simple method for getting posts, not using WP_query and loops.
get_posts() actually makes an instance of WP_Query.
For an example of how to use a custom loop, See http://codex.wordpress.org/Function_Reference/WP_Query#Fixing_errors_with_broken_queries
Filters are applied only when you call template tags, like the_title(), the_date() etc.
So, the problem isn't that you're using get_posts(), but that you're accessing the post_date property directly instead of via get_the_date().