Skip to content

Commit

Permalink
Issue #15 - Don't count trash or auto-draft posts
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Mar 22, 2018
1 parent 3828471 commit 188f990
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions shortcodes/oik-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ function oik_block_post_type_compatible( $post_type, $post_type_object ) {
/**
* Returns the sum total of all posts for a post type
*
* This includes all different statuses, including Trash.
* The user may undelete the content from Trash.
* This includes all different statuses, including 'trash' and 'auto-draft'
* Althought the user may undelete the content from Trash we don't need to worry about them.
* There really shouldn't be that many Auto-drafts!
*
* @param string $post_type
* @return integer total number of posts
*/

function oik_block_count_posts( $post_type ) {
$counts = (array) wp_count_posts( $post_type );
//bw_trace2( $counts, "counts" );
unset( $counts['auto-draft'] );
unset( $counts['trash'] );
bw_trace2( $counts, "counts" );
//$counts = implode( " ", $counts );
$total = array_sum( $counts );
return $total;
Expand Down

0 comments on commit 188f990

Please sign in to comment.