X-Git-Url: https://git.bts.cx/cx.git/blobdiff_plain/9a60ead9e861fcb9c8fb252e4b27aa36d28b7954..cac9928099ba10ab8a7d5ca4005dd78ff11b5ce3:/cx/lib/posts.php diff --git a/cx/lib/posts.php b/cx/lib/posts.php index 7b13166..b187c51 100644 --- a/cx/lib/posts.php +++ b/cx/lib/posts.php @@ -160,6 +160,26 @@ function cx_posts_get(int $limit = 0, int $offset = 0, bool $include_drafts = fa } } +function cx_posts_count(bool $include_drafts = false) { + $sql = 'SELECT + COUNT(post_id) AS _count + FROM posts + WHERE post_is_page == FALSE'; + + if ($include_drafts == false) { + $sql .= ' AND post_is_draft == FALSE'; + } + + $sql .= ';'; + + + foreach (cx_db_query($sql) as $count_details) { + return $count_details['_count']; + } + + return 0; +} + function cx_posts_find_post($post_id) { $sql = 'SELECT post_id,