I hope this question doesn't make me look too stupid!
I am using a plugin called 'Query Multiple Taxonomies' -- it's a fantastic plugin and is written extraordinarily well. http://wordpress.org/plugins/query-multiple-taxonomies/
It does just about everything that I need it to do save one small thing. I've been trying to figure out how to accomplish this last bit for a while now, and I decided that it was time to ask for some help.
You can view the section I'm working on here: http://tunagaming.dyndns.org/?section=tutorials
The drill-down works very well. This is how it is currently set up:
- First page shows platforms.
- Second page shows genres
- Third page shows sub-genres.
This is how I want it to work, except that each of those are custom taxonomies, and I would like to eliminate 'sub-genres' completely in favor of a hierarchical 'genres' taxonomy.
So ultimately, I would like for the drill-down to work like this:
- First page shows platforms.
- Second page shows ONLY parent terms in the taxonomy 'genres'
- Third page shows children of selected parent.
All of this is being called in an archive.php file. Here is the code for reference:
<?php if (is_multitax( array('section', 'platforms', 'genre') ) ){
the_widget('Taxonomy_Drill_Down_Widget', array(
'title' => '',
'mode' => 'lists',
'taxonomies' => array('subgenre')
));?>
<div id="postList">
<h2>Query Results</h2>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<ul><a title="<?php the_title();?>" href="<?php the_permalink();?>"><li>
<span class="image"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></span>
<span class="content">
<h3><?php the_title();?></h3>
<?php the_excerpt(); ?>
</span>
</ul></li></a>
<?php endwhile; ?>
</div>
<?php
}
elseif (is_multitax( array('section', 'platforms') ) ) {
the_widget('Taxonomy_Drill_Down_Widget', array(
'title' => '',
'mode' => 'lists',
'taxonomies' => array('genre')
));
?>
<div id="postList">
<h2>Query Results</h2>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<ul><a title="<?php the_title();?>" href="<?php the_permalink();?>"><li>
<span class="image"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></span>
<span class="content">
<h3><?php the_title();?></h3>
<?php the_excerpt(); ?>
</span>
</ul></li></a>
<?php endwhile; ?>
</div>
<?php
}
else {
the_widget('Taxonomy_Drill_Down_Widget', array(
'title' => '',
'mode' => 'lists',
'taxonomies' => array('platforms') // list of taxonomy names
));
?>
<div id="postList">
<h2>Latest Entries</h2>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<ul><a title="<?php the_title();?>" href="<?php the_permalink();?>"><li>
<span class="image"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></span>
<span class="content">
<h3><?php the_title();?></h3>
<?php the_excerpt(); ?>
</span>
</ul></li></a>
<?php endwhile; ?>
</div>
<?php } ?>
I would love some help in figuring this out, or even some fresh ideas on how to achieve this drill-down. I'm not asking for anyone to code it for me, but it is just a bit over my head. I'm okay with PHP -- not great. So a nudge in the right direction would also be very helpful!
Thanks in advance.
EDIT:
For what it's worth, I believe the answer lies in the plugin's walker.php file. I could be wrong, but here's the code I've been studying this morning:
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
if ( !$element )
return;
$id_field = $this->db_fields['id'];
$id = $element->$id_field;
$child_output = '';
// descend only when the depth is right and there are childrens for this element
if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
foreach ( $children_elements[ $id ] as $child ) {
$this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $child_output );
}
unset( $children_elements[ $id ] );
}
$this->single_el( $output, $element, $depth, $child_output );
}
function single_el( &$output, $term, $depth, $child_output ) {
$data = $this->specific_data( $term, $depth );
$data = array_merge( $data, array(
'term-name' => $term->name,
'is-selected' => in_array( $term->slug, $this->selected_terms ) ? array(true) : false,
'depth' => $depth,
) );
if ( !empty( $child_output ) ) {
$data['children']['child-list'] = $child_output;
}
$full_data = new QMT_Data_Container( $this->taxonomy, $term, $data );
$output .= Taxonomy_Drill_Down_Widget::mustache_render( $this->walker_type . '-item.html', $full_data );
}
abstract function specific_data( $term, $depth );
}