#13943 closed defect (bug) (invalid)
Sticky posts are sticky posts even if they are trashed
Reported by: | bi0xid | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | reporter-feedback, sticky posts |
Focuses: | Cc: |
Description
Hello there.
I have some problem with sticky posts.
I'm using this function to get the last of them:
$sticky = get_option( 'sticky_posts' ); echo '<strong><a href="'.get_permalink($sticky[0]).'">'.get_the_title($sticky[0]).'</a></strong>'; echo '<a href="'.get_permalink($sticky[0]).'">'.get_the_post_thumbnail($sticky[0], 'thumbnail').'</a>';
I have trashed a sticky post, and this function still echoes the post in the trash.
If I delete it permanently it of course disappears.
Change History (4)
Note: See
TracTickets for help on using
tickets.
When using WP_Query to query posts, sticky posts that are trashed will be excluded.
I suppose we could add a filter to get_option('sticky_posts') that excludes any trashed IDs, or better yet unstick any post when it is trashed, but I'm not sure if either of those would be what the expected behavior is.
The code you provide I imagine would work for any post in the trash, not just sticky ones.