Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This site is in beta at: beta2.dixiestarkhome.com , the page for context is: http://beta2.dixiestarkhome.com/taxon/upholstery/sofas-settees/

my custom taxonomy is "taxon", sofas is a child of upholstery.

I want to find the parent taxon, and then do a wp_list_categories on that parent.

This is the code that runs the taxon listing:

<div id="nav" class="bottom-border">
 <?php 
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)

$taxonomy     = 'taxon';
$orderby      = 'name'; 
$show_count   = 0;      // 1 for yes, 0 for no
$pad_counts   = 0;      // 1 for yes, 0 for no
$hierarchical = 1;      // 1 for yes, 0 for no
$title        = '';

$args = array(
  'taxonomy'     => $taxonomy,
  'orderby'      => $orderby,
  'show_count'   => $show_count,
  'pad_counts'   => $pad_counts,
  'hierarchical' => $hierarchical,
  'title_li'     => $title,
  'depth'        => '1'
);
?>

<ul class="navigation-list">
<?php wp_list_categories( $args ); ?>
</ul>


 <?php 
$term = $wp_query->queried_object;
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$args2 = array(
  'taxonomy'     => $taxonomy,
  'orderby'      => $orderby,
  'show_count'   => $show_count,
  'pad_counts'   => $pad_counts,
  'hierarchical' => $hierarchical,
  'title_li'     => $title,
  'depth'        => '1',
  'child_of'     => $term->term_id

);
?>

<ul id="sub_nav">
<?php wp_list_categories( $args2 ); ?>
</ul>

If I am on the Uphostery page it works fine and shows the children. If I am on the sofa's page it just says "No Categories"

To recap, I need to find the taxon parent and then list the child taxons...

Ideas?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

the answer actually turned out to be incredibly simple. Since I was already:

$term = $wp_query->queried_object;

I could simple do:

$term->parent
share|improve this answer
2  
I would recommend $term = get_queried_object();. Or, if you don't need the term for anything else: $parent = get_queried_object()->parent;. –  chrisguitarguy Sep 30 '12 at 16:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.