[wp-trac] [WordPress Trac] #43294: Sticky class should be added regardless of where posts are queried
WordPress Trac
noreply at wordpress.org
Tue Feb 13 17:49:48 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: Posts, Post Types | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------------+------------------------------
Changes (by birgire):
* component: Query => Posts, Post Types
Comment:
@Selrond Welcome to WordPress core trac.
The {{{get_post_class()}}} function was introduced in
[https://core.trac.wordpress.org/browser/tags/2.7/wp-includes/post-
template.php#L447 2.7] and there the sticky part was already with a
{{{is_home()}}} check:
{{{
// sticky for Sticky Posts
if ( is_sticky($post->ID) && is_home())
$classes[] = 'sticky';
}}}
The sticky posts are injected within the {{{WP_Query::get_posts()}}}
[https://github.com/WordPress/WordPress/blob/5e190dc08450ccca05d32ed822a09e5d843a1d16
/wp-includes/class-wp-query.php#L3047 src]:
{{{
// Put sticky posts at the top of the posts array
$sticky_posts = get_option( 'sticky_posts' );
if ( $this->is_home && $page <= 1 && is_array( $sticky_posts ) && ! empty(
$sticky_posts ) && ! $q['ignore_sticky_posts'] ) {
// ...
}
}}}
where the {{{$this->is_home && $page <= 1}}} restrictions looks very
similar to the:
{{{
if ( is_home() && ! is_paged() ) {
}}}
check in {{{get_post_class()}}} in 4.9.
So the {{{is_home()}}} check looks normal here or maybe I'm
misunderstanding your proposal @Selrond ?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43294#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list