WordPress Get all ids of categories of the post


Example

Code

$categories = get_the_category();
 foreach( $categories as $category ) {
    echo  $category->term_id . '<br />';
}

Output

All ids of categories of the current page, one on each line.