get_post_class() does not always apply filter to output
|Reported by:||F J Kaiser||Owned by:|
|Component:||Posts, Post Types||Keywords:||has-patch dev-feedback|
Currently the post class function/template tag simply returns an empty array for 404 requests. The reason is simple: The output gets generated based on the return values of get_post().
This avoids using it to style parts of the 404 template using the post_class filter.
Use case: In one theme I'm currently developing, I use the post_class filter to override the parent themes classes with some grid classes from a CSS framework. This avoids duplicating the templates and handle the positions, etc. of the template parts with a simple callback for the post_class filter. The attached patch makes sure that classes get added, instead of just returning an empty array if no $post->ID is present. It doesn't harm any other callback (or interfere with it).
The attached patch is tested in current 3.4.2 and 3.5 Beta. It is built against the v3.5 nightly build - revision 606806.
Sidenote: The somehow wired phpDocBlock comment was also "fixed".
Change History (37)
comment:2 F J Kaiser — 17 months ago
- Summary changed from Allow post class for 404 requests to get_post_class() does not always apply filter to output
- Type changed from enhancement to defect (bug)
comment:8 MikeSchinkel — 16 months ago
- Cc mike@… added
comment:15 follow-ups: ↓ 17 ↓ 18 scribu — 16 months ago
comment:16 scribu — 16 months ago
- Keywords close added; dev-feedback removed
comment:17 in reply to: ↑ 15 MikeSchinkel — 16 months ago
comment:22 nacin — 16 months ago
- Keywords close removed
- Type changed from defect (bug) to enhancement
comment:24 in reply to: ↑ 23 nacin — 16 months ago
- Keywords needs-patch added; has-patch dev-feedback removed