cx_db_exec($sql, $post_id);
}
-function cx_posts_get(int $limit = 0, bool $include_drafts = false) {
+function cx_posts_get(int $limit = 0, int $offset = 0, bool $include_drafts = false) {
$sql = 'SELECT
post_id,
post_slug,
if ($limit > 0) {
$sql .= ' LIMIT ' . $limit;
}
+
+ if ($offset > 0) {
+ $sql .= ' OFFSET ' . $offset;
+ }
$sql .= ';';
}
}
+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,