wordpress query show all categories from post code example
Example 1: wordpress display post categories
<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>
Example 2: wp get all post categories
$categories = get_categories();
foreach($categories as $category) {
echo '<div class="col-md-4"><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></div>';
}