#23559 closed enhancement (wontfix)
Sticky single post page doesn't have .sticky class
Reported by: | sgr33n | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.7 |
Component: | Posts, Post Types | Keywords: | 2nd-opinion |
Focuses: | template | Cc: |
Description
As explained in summary, it's impossible to style a single page for a sticky post without modifying content.php, why this? it's a behavior wanted.
wp-includes\post-template.php, line 344:
// sticky for Sticky Posts if ( is_sticky($post->ID) && '''is_home()''' && !is_paged() ) $classes[] = 'sticky';
Thanks :)
Change History (11)
#4
@
12 years ago
So...
Why this? It should be good to have the same class on the single page. You can even overwrite the default style via css by using .single .sticky
#5
@
12 years ago
- Keywords 2nd-opinion added
A workaround:
function sticky_class_for_single_post_23559( $classes, $class, $post_id ) { if ( ! in_array( 'sticky', $classes ) && is_sticky( $post_id ) && ! is_paged() ) $classes[] = 'sticky'; return $classes; } add_filter( 'post_class', 'sticky_class_for_single_post_23559', 10, 3 );
#6
follow-up:
↓ 9
@
12 years ago
Thanks for your workaround Sergey... anyway my ticket was for ask why this choice to exclude is_single(). Maybe the decision was taken in the past for something now outdated, so it could make sense to activate it again.
#9
in reply to:
↑ 6
@
10 years ago
Replying to sgr33n:
why this choice to exclude is_single().
Sticky posts are meant as a way to bump the priority of a specific post, regardless of the date it was published and its place in the timeline. Since it only has to be distinguished when displayed among other posts, there is no immediate need for that information on single where it is the only post displayed.
#10
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
I agree with obenland
is_home()
was added in [8847] (for #7712).