March 2011
2 posts
2 tags
Count Published Sticky Posts in WordPress
get_option( 'sticky_posts' ); The problem with the above line of code, is that it also returns draft and trashed sticky posts. So to get the count of published posts only, you’ll need to query for it. function get_sticky_posts_count() { global $wpdb; $sticky_posts = array_map( 'absint', (array) get_option('sticky_posts') ); return count($sticky_posts) > 0 ? $wpdb->get_var(...
Mar 15th
27 notes
2 tags
Mar 2nd
4 notes