Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 96044

iheartlolcats on "How-to: Show third level term titles on taxonomy template"

$
0
0

I'll try my best to describe the issue I'm having :)

I have a custom post type: "menus"
I have a hierarchical taxonomy: "menu-categories"

First, here's an example of how my taxonomy-menu-categories.php looks now:
http://d.pr/i/UiHP

You can see by this example, that my category structure for the active page is as follows:
Liquor > After Dinner

All fine and dandy... until, we get to 3 levels deep. For example, in the "After Dinner" category I have three categories. The menu items show in the example provided, but the category titles do not. This is how I would like it to show:
http://d.pr/i/cJhn

This is my code:

<?php
	$posttype = 'menus';
	$taxonomy = get_query_var( 'taxonomy' );
	$term = get_query_var( 'term' );
	$term_id = get_query_var( 'term_id' );
	$current_term = get_term_by( 'slug', $term, $taxonomy );
?>

<h1><?php _e( 'Menus', 'themename' ); ?></h1>

<aside class="main-categories">
	<ul>
	<?php
		$tax_terms = get_terms($taxonomy, 'orderby=term_order&order=ASC&hide_empty=0&parent=0');
		foreach ($tax_terms as $tax_term) {
			echo '<li';
			if ( $term == $tax_term->slug ) {
				echo ' class="active"';
			}
			echo '>';
			echo '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View %s Menu" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a>';
			echo '</li>';
		}
	?>
	</ul>
</aside>

<div class="menu-content">

	<aside>
		<ul class="tabs">
		<?php
			$custom_terms = get_terms($taxonomy, 'orderby=term_order&order=ASC&hide_empty=0&parent='.$current_term->term_id.'');
			foreach($custom_terms as $custom_term) {
				wp_reset_query();
				$args = array('post_type' => $posttype,
					'posts_per_page' => '-1',
					'tax_query' => array(
						array(
							'taxonomy' => $taxonomy,
							'field' => 'slug',
							'terms' => $custom_term->slug
						),
					),
				);
				$loop = new WP_Query($args);
				if($loop->have_posts()) {
					echo '<li><a href="#menu-item-' . $custom_term->slug .'">'.$custom_term->name.'</a></li>';
				}
			}
		?>
		</ul>
	</aside>

<?php

	$custom_terms = get_terms($taxonomy, 'orderby=term_order&order=ASC&hide_empty=0&parent='.$current_term->term_id.'');
	foreach($custom_terms as $custom_term) {
		wp_reset_query();
		$args = array('post_type' => $posttype,
			'posts_per_page' => '-1',
			'tax_query' => array(
				array(
					'taxonomy' => $taxonomy,
					'field' => 'slug',
					'terms' => $custom_term->slug
				),
			),
		);

		echo '<article class="tab-content" id="menu-item-' . $custom_term->slug .'">';

		if ( $custom_term->description != '' ) {
			echo '<div class="term-description">';
			echo $custom_term->description;
			echo '</div>';
		}

		echo '<div class="columnize">';
		$loop = new WP_Query($args);
		if($loop->have_posts()) {
			while($loop->have_posts()) : $loop->the_post();
		?>

		<dl>
			<dt><?php the_title(); ?></dt>
			<dd>
				<?php the_content(); ?>
				<div class="tags">
				<?php
					if ( has_term( 'vegetarian', 'menu-tags' ) ) {
						echo '<span class="tag tag-vegetarian" title="Vegetarian">Vegetarian</span>';
					}
					if ( has_term( 'gluten-free', 'menu-tags' ) ) {
						echo '<span class="tag tag-glutenfree" title="Gluten Free">Gluten Free</span>';
					}
				?>
				</div>
			</dd>
		</dl>

		<?php
			endwhile;
		}
		echo '</div>';
		echo '</article>';
	}
?>

</div>
<!-- /menu-content -->

Any help is appreciated! Thanks :)


Viewing all articles
Browse latest Browse all 96044

Trending Articles