Assigning individul post Id's to menu items
-
Hi, a while back i found the code below on a forum.
It does exactly what i would like it to do; it displays a menu made up of a custom taxonomy without any anchors, in which a ‘current’ class gets added to the list items when applicable.
The problem is that this code doesnt give individual classes to each list item so i cant style them individually. Does anyone know how i might add them?
<?php // Get terms for post $currentterm = get_the_terms( $post->ID , 'product-types' ); // Loop over each item since it's an array if ( $currentterm != null ){ foreach( $currentterm as $current ) { } } $terms = get_terms('product-types', array( 'orderby' => 'ID', )); foreach ($terms as $term) { $class = $current->slug == $term->slug ? 'current' : 'notCurrent' ; echo '<li class="'. $class .'">' . $term->slug . '</li>'; } unset($current); ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Assigning individul post Id's to menu items’ is closed to new replies.