Post

Functions


// Retrieve all posts
get_post();

// Retrieve post by id = 5
get_post(['id' => 5]);

// Retrieve posts with category relation
get_post(['with' => 'category']);

// For retrieving post with many relations pass an array with relations names
get_post(['with' => ['category', 'author']]);

mixed get_post ( $options = [] )
$options array
  • id (int/array) - post id
  • alias (string/array) - post slug
  • author (int/array) - post author
  • category (int/array) - category id
  • language (string/array) - post language
  • category_alias (string/array) - category slug
  • post_status (int/array) - post status
  • order (string) - post order
  • group_by (string) - group by
  • limit (int) - post limit
  • offset (int) - offset
  • category_status (int/array) - category status
  • check_category_status (boolean) - by default true
  • with (string/array) - relations (available relations: category, author)
  • where (mixed) - additional condition, details
Returns array of Post object collection or single Post object.

// Retrieve post by id = 5
get_post_by('id', 5);

// Retrieve post by id = 5, 7 
get_post_by('id', [5, 7]);

mixed get_post_by ( $key, $value, $options = [] )
$key string
  • id - post id
  • alias - post slug
  • author - post author
  • category - category id
  • language - post language
  • category_alias (string/array) - category slug
  • post_status - post status
  • category_status - category status
$value mixed The value
$options array
  • id (int/array) - post id
  • alias (string/array) - post slug
  • author (int/array) - post author
  • category (int/array) - category id
  • language (string/array) - post language
  • category_alias (string/array) - category slug
  • post_status (int/array) - post status
  • order (string) - post order
  • group_by (string) - group by
  • limit (int) - post limit
  • offset (int) - offset
  • category_status (int/array) - category status
  • check_category_status (boolean) - by default true
  • with (string/array) - relations (available relations: category, author)
  • where (mixed) - additional condition, details
Returns array of Post object collection or single Post object. On failure return an empty array and if value was the string or integer then returns null.
mixed get_popular_post ( $limit = 10, $options = [] )
$limit integer Post limit, by default 10
$options array
  • id (int/array) - post id
  • alias (string/array) - post slug
  • author (int/array) - post author
  • category (int/array) - category id
  • language (string/array) - post language
  • category_alias (string/array) - category slug
  • post_status (int/array) - post status
  • group_by (string) - group by
  • offset (int) - offset
  • category_status (int/array) - category status
  • check_category_status (boolean) - by default true
  • with (string/array) - relations (available relations: category, author)
  • where (mixed) - additional condition, details
Returns array of Post object collection or single Post object.
mixed get_last_post ( $limit = 10, $options = [] )
$limit integer Post limit, by default 10
$options array
  • id (int/array) - post id
  • alias (string/array) - post slug
  • author (int/array) - post author
  • category (int/array) - category id
  • language (string/array) - post language
  • category_alias (string/array) - category slug
  • post_status (int/array) - post status
  • group_by (string) - group by
  • offset (int) - offset
  • category_status (int/array) - category status
  • check_category_status (boolean) - by default true
  • with (string/array) - relations (available relations: category, author)
  • where (mixed) - additional condition, details
Returns array of Post object collection or single Post object.
update_post_counter ( $id, $count = 1 )
$id integer Post id
$count integer By default 1

Post Object

$id int Post id
$category_id int Post related category id
$status int Post status
$title string Post title
$slug string Post slug
$introtext string Post intro text
$fulltext string Post full text
$hits int Post view counter
$image string Post image
$post_type string Post type
$published_at string Post published date
$publish_up string Post published up date
$publish_down string Post published down date
$language string Post language
$view string Post view
$version int Post version (update counter)
$reference mixed Post reference
$created_by int Post author id
$created_at string Post created date
$modified_by int Post edited user id
$modified_at string Post edited date
$meta_title string Post meta title
$meta_keywords string Post meta keywords
$meta_description string Post meta description
$category object Category object (relation)
$author object User object (relation)

Category Object

$id int Category id
$parent_id int Category parent id
$status int Category status
$image string Category image
$title string Category title
$slug string Category slug
$description string Category description
$language string Category language
$depth int Category depth
$lft int Category nested left key
$rgt int Category nested right key
$created_by int Category author id
$created_at string Category created date
$modified_by int Category edited user id
$modified_at string Category edited date
$meta_title string Category meta title
$meta_keywords string Category meta keywords
$meta_description string Category meta description
$posts array Post object collection (relation)
$post_count int Post count
$author object User object (relation)

User Object

$id int User id
$username string User username
$email string User email
$role string User role
$status int User status
$auth_key string User auth key
$password_hash string User password hash
$password_reset_token string User password reset token
$created_at string User created date
$profile object User profile (relation)
$posts object collection Related posts (relation)