#15883 closed defect (bug) (invalid)
when using get_posts() post_date does not get localized
| Reported by: | bmb | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 3.0.3 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
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)
#3
in reply to: ↑ 2
@
16 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
@
16 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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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().