0

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?

2

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

$term = $wp_query->queried_object;

I could simple do:

$term->parent
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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