Sticky Posts is a feature of WordPress to allow users to "stick" posts to the front page. It's almost like curation, but the user doesn't have control over their order.
Use Case
As far as I'm aware, we've never built around or advised that our clients use this feature, but yet it's present in the admin and if a client actually used it, it could potentially cause significant issues. To illustrate this, simply mark an old post as sticky (not the most recent post), then hop into wp shell and run $q = new WP_Query( [ 'posts_per_page' => 1 ] );. One would expect this query to contain one post, the most recent one. But, because of sticky posts, it contains two ($q->post_count should confirm this), with the first post being the sticky one and the second post being the most recent. You could even use post__in to make this even more baffling, e.g. $q = new WP_Query( [ 'post__in' => [ 1178 ] ] ); gives me 2 posts in my demo site 😧.
You can imagine the consequences here if on this site we ran a query in the sidebar for latest posts, we had a couple of queries in the supernav, etc. -- the sticky post could well be the first post in all of these places! WP_Query has an argument ignore_sticky_posts which would prevent this behavior, but it's easy to forget to add this to all custom queries.
High-level, the solution to this should both remove the UI for sticky posts (in classic and gootz) and disable the functionality. Sticky posts are stored in an option, so a potential solution would be to short circuit this option so it always returns an empty value, even if there actually are historical sticky posts in the database.
Description
Sticky Posts is a feature of WordPress to allow users to "stick" posts to the front page. It's almost like curation, but the user doesn't have control over their order.
Use Case
As far as I'm aware, we've never built around or advised that our clients use this feature, but yet it's present in the admin and if a client actually used it, it could potentially cause significant issues. To illustrate this, simply mark an old post as sticky (not the most recent post), then hop into
wp shell
and run$q = new WP_Query( [ 'posts_per_page' => 1 ] );
. One would expect this query to contain one post, the most recent one. But, because of sticky posts, it contains two ($q->post_count
should confirm this), with the first post being the sticky one and the second post being the most recent. You could even usepost__in
to make this even more baffling, e.g.$q = new WP_Query( [ 'post__in' => [ 1178 ] ] );
gives me 2 posts in my demo site 😧.You can imagine the consequences here if on this site we ran a query in the sidebar for latest posts, we had a couple of queries in the supernav, etc. -- the sticky post could well be the first post in all of these places!
WP_Query
has an argumentignore_sticky_posts
which would prevent this behavior, but it's easy to forget to add this to all custom queries.High-level, the solution to this should both remove the UI for sticky posts (in classic and gootz) and disable the functionality. Sticky posts are stored in an option, so a potential solution would be to short circuit this option so it always returns an empty value, even if there actually are historical sticky posts in the database.