Support » Themes and Templates » Tags Drop List as Navigation in Category Page

  • I’m trying to make a kind of drop list sub navigation scheme using tags in posts for specific categories.

    So, I have various pages that list posts from a certain category. On each category listing page, I’d like to show a drop list of TAGS from the posts ONLY in the current category.

    NOTE: the drop list is necessary since these tags may add up in categories that have numerous posts listed. Simply showing a block or “cloud” of linked text could get too long and cluttered to display cleanly.


    As seen in the link above, I have a Wine & Dine category listing page that shows all merchants relevant to only that category.

    In the post for A’Romas I have a tag entered Coffee and Tea. Likewise, Cellars of Sonoma has the tag Wine Bar and so on. These tags then are simply refinements or keywords belonging to the parent category of Wine & Dine.

    To utilize this drop list navigation scheme from post tags in a specific category, I need two things to happen:

    A drop list is shown at the top of the list of Wine & Dine category merchants with the tags found within those matching category posts (such as Coffee and Tea, Wine Bar, etc.). When one of these tags is selected from the drop list, a listing page is shown with just the posts that match that tag within Wine & Dine category.

    Example: once at the Wine & Dine category page, selecting Coffee and Tea from the drop list only shows A’Romas (since there’s only one coffee and tea shop listed). Selecting Wine Bar from the drop list would show both Cellars of Sonoma and Wine Spectrum Shop+Bar (since both share the selected Wine Bar tag).

    Once a tag listing page is shown, the other tags in the drop menu for the Wine & Dine category are still available. This way, when a person selects the Coffee and Tea tag from the drop list, they can still move on to other tags in the drop list such as Wine Bar without first going back to the complete Wine & Dine category listing page.

    In other words, the tags drop list is a sub navigation for refining the views of all posts within the Wine & Dine category.



    I’ve found a lot of info about how to display posts with certain tags, but it’s not as a drop list that is preserved as a link menu for a category.

    I also looked at using Custom Fields, but that seems like a complex alternative to tags which is a perfectly good method. Also, I couldn’t find any info about how to turn Custom Fields into a drop list as described above.

    Thanks for any help!

Viewing 1 replies (of 1 total)
  • sassymonkey


    One potential plugin solution and an imperfect solution have since come up:

    1) The WP Smart Sort plugin seems to be a solution for sorting based on any number of custom fields in posts, but I’ll be buggered if I can figure out how to use the thing.

    2) Currently I’m using categorized posts for descriptions of each merchant in a neighborhood business association. Categories are such things as Retail, Wine & Dine, etc. Each post also utilizes (hopefully) a single word Tag that acts as a sub category or type nav block of merchants in the parent Category (like Retail). Example for Tags on merchants in Retail category are Thrift, Clothing, etc.

    The Retail page then uses a custom template file with three sections and two loops:
    A) First loop for top static content that is entered into the page body field in the Admin section which is a nice place for intro text
    B) Tags display from just the posts that are in the Retail category
    C) Second loop for displaying those posts that are categorized as Retail

    Major problem here (besides IE6 and 7 refusing to render this as a multiline inline list without bullets like ALL other browsers do without problems) is that clicking a Tag link works to send the viewer to a page with just posts that match the tag, though the Tags sub category block disappears instead of persisting like the WP Snap! alphanumeric sorting plugin did.

    Also, it’s not a drop list. Since there aren’t that many merchants and their respective Tags, it’s not too much of an issue. Still would like a drop list though viewers are less likely to see and use what’s enclosed in a drop list I suppose.

    Here’s the Retail custom template code:

    <h1><?php the_title(); ?></h1>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<?php the_content(''.__('Read the rest of this entry <span class="meta-nav">&raquo;</span>', 'sandbox').''); ?>
    		<?php link_pages("\t\t\t\t\t<div class='page-link'>".__('Pages: ', 'sandbox'), "</div>\n", 'number'); ?>
    		<?php endwhile; endif; ?>
    		<?php rewind_posts(); ?>
    		<?php query_posts('category_name=retail&orderby=title&order=asc'); ?>
    		<div id="categorySubNav">
    		<ol id="tagsSubNav"><li>Sort by Type:</li><?php
    		if (have_posts()) : while (have_posts()) : the_post();
    		   $posttags = get_the_tags();
    			if ($posttags) {
    				foreach($posttags as $tag) {
    					$all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
    		endwhile; endif; 
    		$tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
    		//echo '<pre>'.print_r($tags_arr, true).'</pre>';
    		  foreach ($tags_arr as $tag) {
    			 echo '<li><a href="/tag/'.$tag.'">'.$tag.'</a></li>';
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		    <div class="post" id="post-<?php the_ID(); ?>">
    		        <h2><?php the_title(); ?></h2>
    		        <div class="entry">
    					<?php the_content(''.__('Read the rest of this entry <span class="meta-nav">&raquo;</span>', 'sandbox').''); ?>
    					<?php link_pages("\t\t\t\t\t<div class='page-link'>".__('Pages: ', 'sandbox'), "</div>\n", 'number'); ?>
    		  <?php endwhile; endif; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Tags Drop List as Navigation in Category Page’ is closed to new replies.