WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 3 months ago

#23559 new enhancement

Sticky single post page doesn't have .sticky class

Reported by: sgr33n Owned by:
Milestone: Awaiting Review 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 (8)

comment:1 sgr33n14 months ago

  • Component changed from Themes to Template

comment:2 SergeyBiryukov14 months ago

  • Version changed from 3.5.1 to 2.7

is_home() was added in [8847] (for #7712).

comment:3 sgr33n14 months ago

Replied on that Ticket,
Thanks!

comment:4 sgr33n14 months 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

comment:5 SergeyBiryukov14 months 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 );

comment:6 sgr33n14 months 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.

comment:7 goto109 months ago

  • Cc dromsey@… added

comment:8 nacin3 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added
Note: See TracTickets for help on using tickets.