Skip to content

Instantly share code, notes, and snippets.

@shortcircuit3
Created August 6, 2012 16:15
Show Gist options
  • Save shortcircuit3/3276022 to your computer and use it in GitHub Desktop.
Save shortcircuit3/3276022 to your computer and use it in GitHub Desktop.
// Find parent category for related posts
global $post;
$category = get_the_category();
$cat_tree = get_category_parents($category[0]->term_id, FALSE, ':', TRUE);
$top_cat = split(':',$cat_tree);
$parent = $top_cat[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment