[wp-trac] [WordPress Trac] #18035: ignore_sticky_posts fails to remove sticky class
WordPress Trac
noreply at wordpress.org
Wed Sep 20 03:13:42 UTC 2023
#18035: ignore_sticky_posts fails to remove sticky class
------------------------------------+-----------------------------
Reporter: mikkelbreum | Owner: johneckman
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future Release
Component: Query | Version: 3.2
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses: template
------------------------------------+-----------------------------
Changes (by peterwilsoncc):
* keywords: has-patch, dev-feedback => has-patch dev-feedback
Comment:
Another contributor asked me to take a look at this.
As the `sticky` class on posts has worked in roughly the same way for
approximately fifteen years, I think it would be too risky to change it
now.
Possibly we could add a `hoisted` class for sticky posts that have been
raised to the top with the block of code looking something like this
(possibly with an `is_main_query()` thrown in for good measure):
{{{#!php
<?php
global $wp_query;
// ...
// Sticky for Sticky Posts.
if ( is_sticky( $post->ID ) ) {
if ( is_home() && ! is_paged() ) {
$classes[] = 'sticky';
if ( true !== (bool) $wp_query->get( 'ignore_sticky_posts'
) ) {
$classes[] = 'hoisted';
}
} elseif ( is_admin() ) {
$classes[] = 'status-sticky';
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/18035#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list