Skip to content

Instantly share code, notes, and snippets.

@davemac
Created December 10, 2011 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemac/1456920 to your computer and use it in GitHub Desktop.
Save davemac/1456920 to your computer and use it in GitHub Desktop.
Wordpress display the current category's parent, and link to it
<?php
$cat = get_the_category();
$parentCatName = get_cat_name($cat[0]->parent);
$parentCatLink = get_category_link($cat[0]->parent);
echo '<a href="'.$parentCatLink.'">'.$parentCatName.'</a>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment