I need to write a custom function for wp_list_categories so instead of displaying a hierarchical list of links they are instead a list of checkboxes with the parent terms being displayed as h3 tags.
The final output will look like http://ift.tt/1xvgS3E
Here is the PHP code in my WordPress template file...
<?php
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$taxonomy = 'tags';
$orderby = 'name';
$show_count = 1; // 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
);
?>
<ul class="categories">
<?php wp_list_categories( $args ); ?>
</ul>
Here is the HTML that <?php wp_list_categories( $args ); ?> outputs...
<ul class="categories">
<li class="cat-item cat-item-21"><a href="http://ift.tt/13TBGWc" >Client</a> (0)
<ul class='children'>
<li class="cat-item cat-item-22"><a href="http://ift.tt/1xvgS3G" >BMW</a> (3)
</li>
</ul>
</li>
<li class="cat-item cat-item-25"><a href="http://ift.tt/13TBGWe" >Section</a> (0)
<ul class='children'>
<li class="cat-item cat-item-27"><a href="http://ift.tt/1xvgTVh" >Automotive</a> (3)
</li>
<li class="cat-item cat-item-28"><a href="http://ift.tt/1xvgSk1" >Property</a> (2)
</li>
</ul>
</li>
<li class="cat-item cat-item-26"><a href="http://ift.tt/13TBFBw" >Service</a> (0)
<ul class='children'>
<li class="cat-item cat-item-29"><a href="http://ift.tt/1xvgSk3" >Branding</a> (3)
</li>
<li class="cat-item cat-item-30"><a href="http://ift.tt/1xvgSk5" >Email</a> (3)
</li>
<li class="cat-item cat-item-31"><a href="http://ift.tt/13TBGWi" >Website</a> (2)
</li>
</ul>
</li>
</ul>
The checkbox code I would like each term to be displayed as will form a filtering system which can be seen here http://ift.tt/1xvgS3E
<div class="tags">
<h3>service</h3>
<label><input type="checkbox" id="type-Website" rel="Website">Website</label>
<label><input type="checkbox" id="type-Email" rel="Email">Email</label>
<label><input type="checkbox" id="type-Branding" rel="Branding">Branding</label>
<h3>sector</h3>
<label><input type="checkbox" id="type-Automotive" rel="Automotive">Automotive</label>
<label><input type="checkbox" id="type-Property" rel="Property">Property</label>
</div>
I would still like to keep the checkboxes hierarchical as in the example above, but the titles in the h3 tags are parent terms and I do not want these as checkboxes, how do I do all this? :)
Aucun commentaire:
Enregistrer un commentaire