Category

Functions


// Retrieve all categories
get_category();

// Retrieve category by id = 5
get_category(['id' => 5]);

// Retrieve category with post relation
get_category(['with' => 'post']);

// Retrieve 4 popular post for each category
get_category(['post_group_limit' => 4, 'with' => ['post' => ['order' => 'hits DESC']]]);

// Retrieve 4 last created post for 3 last created categories
get_category(['order' => 'created_at DESC', 'limit' => 3,  'post_group_limit' => 4, 'with' => ['post' => ['order' => 'created_at DESC']]]);

mixed get_category ( $options = [] )
$options array
  • id (int/array) - category id
  • alias (string/array) - category slug
  • author (int/array) - category author
  • language (string/array) - category language
  • order (string) - category order (by default lft ASC)
  • group_by (string) - group by
  • limit (int) - category limit
  • offset (int) - offset
  • category_status (int/array) - category status
  • post_group_limit (int) - use when you need to retrieve a certain number of posts for each category
  • with_root (boolean) - retrive with root (by default false)
  • depth (int) - depth
  • exclude (mixed) - category id or alias you want to exclude from retrieving
  • with (string/array) - relations (available relations: post, author, post_count)
  • where (mixed) - additional condition, details
Returns array of Category object collection or single Category object.

// Retrieve category by id = 5
get_category_by('id', 5);

// Retrieve category by id = 5, 7 
get_category_by('id', [5, 7]);

mixed get_category_by ( $key, $value, $options = [] )
$key string
  • id - category id
  • alias - category slug
  • author - category author
  • language - category language
  • category_status - category status
$value mixed The value
$options array
  • id (int/array) - category id
  • alias (string/array) - category slug
  • author (int/array) - category author
  • language (string/array) - category language
  • order (string) - category order (by default lft ASC)
  • group_by (string) - group by
  • limit (int) - category limit
  • offset (int) - offset
  • category_status (int/array) - category status
  • post_group_limit (int) - use when you need to retrieve a certain number of posts for category
  • with_root (boolean) - retrive with root (by default false)
  • depth (int) - depth
  • exclude (mixed) - category id or alias you want to exclude from retrieving
  • with (string/array) - relations (available relations: post, author, post_count)
  • where (mixed) - additional condition, details
Returns array of Category object collection or single Category object. On failure return an empty array and if value was the string or integer then returns null.
mixed get_category_parent ( $category, $level = 1, $options = [] )
$category object Category object
$level mixed 1 - retrieve first parent, null - retrieve all, by default 1
$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)
Returns array of Category object collection or single Category object.
array get_category_parent_ids ( $category, $level = 1 )
$category object Category object
$level mixed 1 - retrieve first parent id, null - retrieve all ids, by default 1
Returns array of ids.
mixed get_category_children ( $category, $level = 1, $options = [] )
$category object Category object
$level mixed 1 - retrieve first level children, null - retrieve all nested childrens, by default 1
$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)
Returns array of Category object collection or single Category object.
array get_category_children_ids ( $category, $level = 1 )
$category object Category object
$level mixed 1 - retrieve first level children id, null - retrieve all nested children ids, by default 1
Returns array of ids.
mixed get_root_category ( )
Returns Category object.
mixed get_default_category ( )
Returns Category object.

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)

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)

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)