Index: commonblocks.plugin.php =================================================================== --- commonblocks.plugin.php (revision 3220) +++ commonblocks.plugin.php (working copy) @@ -136,12 +136,26 @@ $limit = 5; }; - $block->recent_comments = Comments::get( array( - 'limit'=>$limit, - 'status'=>Comment::STATUS_APPROVED, - 'type'=>Comment::COMMENT, - 'orderby'=>'date DESC', - ) ); + $offset = 0; + $published_posts = 0; + $content = array(); + + do { // get the comments + $content = Comments::get( array( + 'limit'=>$limit, + 'status'=>Comment::STATUS_APPROVED, + 'type'=>Comment::COMMENT, + 'offset'=>$offset, + 'orderby'=>'date DESC', + ) ); + // check the posts + foreach ($content as $comment ) { + if ( $comment->post->status ) == Post::status( 'published' ) { ++$published_posts; } + } + } while ( $published_posts < $limit ); + + // return the first {$limit} posts + $block->recent_comments = array_slice( (array) $content, 0, $limit ); } public function action_block_content_recent_posts( $block, $theme )