how to display all categories in wordpress?

In the code you gave us you are selected the categories selected for the specific post get_the_ID() is doing that part. However you would be best off using another function get_categories() https://developer.wordpress.org/reference/functions/get_categories/ which you would do like so:

$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>';
}

You can also pass through arguments to be more specific (if needed) – see https://developer.wordpress.org/reference/functions/get_terms/ for details on what you can pass through

Leave a Comment