0

The value of get_option('sticky_posts') includes those that are in the trash. How can I get a value minus stickies that are in the trash?

var $stickies = count(get_option('sticky_posts'));
0

Why is that even happening aside, from quick look at core it does the following to achieve that in WP_Posts_List_Table class:

$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.