Return to Snippet

Revision: 29473
at July 30, 2010 00:56 by S_Park


Initial Code
<?php
  $ID = $wp_query->posts[0]->ID;
  $postcat = get_the_category($ID);
  $cat = $postcat[0]->cat_ID;
  $parent = get_category ($cat);
    if ($parent->parent) {
      wp_list_categories ('child_of=' . $parent->parent);
      } else {
      wp_list_categories ('child_of=' . $cat);
    }
?>

Initial URL


Initial Description


Initial Title
Wordpress: Retrieve post categories outside of the loop

Initial Tags
wordpress, category

Initial Language
PHP