Looping through WordPress post categories
To loop through WordPress post categories, copy and paste the code below into the file you wish to display them on.
<?php foreach ( get_categories() as $category ) : echo $category->name; endforeach; ?>
get_categories() not working?
Is your get_categories() function not showing any matches? You may need to allow the display of empty categories. In order to solve this, try replacing the first line of the foreach loop above with this one below.
foreach ( get_categories( array( 'hide_empty' => false ) ) as $category ) :