[wp-trac] [WordPress Trac] #43294: Sticky class should be added regardless of where posts are queried
WordPress Trac
noreply at wordpress.org
Mon Feb 12 12:18:29 UTC 2018
#43294: Sticky class should be added regardless of where posts are queried
-------------------------+-----------------------------
Reporter: Selrond | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
post_class() function is only adding `.sticky` class when `is_home()` is
true, basically
> ...if the query is for the blog homepage.
[http://developer.wordpress.org/reference/functions/is_home/ is_home()
reference]
Check out [https://core.trac.wordpress.org/browser/trunk/src/wp-includes
/post-template.php#L512 the code] in
[https://core.trac.wordpress.org/browser/trunk/src/wp-includes/post-
template.php#L461 get_post_class()] function
{{{
#!php
512 // sticky for Sticky Posts
513 if ( is_sticky( $post->ID ) ) {
514 if ( is_home() && ! is_paged() ) {
515 $classes[] = 'sticky';
516 } elseif ( is_admin() ) {
517 $classes[] = 'status-sticky';
518 }
519 }
}}}
This behavior complicates recognizing sticky post when using custom
queries, as they're mostly used outside of homepage, which fails
`is_home()` check, requiring extra work to add `.sticky` class where it
should be.
I suggest removing the `is_home()` check from the condition in
`get_post_class()` function.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43294>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list