Limit the results returned by get_the_term_list
-
Hi,
I have created a custom post type for a restaurant menu. In this I have created some custom taxonomies for the menus the dishes appear in.
I have called on these in the single-dish.php file I have created (think of it as the single.php for posts). This is the code I have used to list out the other menus this dish appears in…
<?php // Let's do it again for another one $taxo_text = ""; $the_menu = get_the_term_list( $post->ID, 'the_menu', 'This dish can be found in: ', ', ', '' ); if ( '' != the_menu ) { $taxo_text .= "$the_menu<br />\n"; } ?>
This is great, but when I have a dish that is in a sub category (or “menu”) of the main menus i.e A La Carte Menu > Starters it lists it out like this.
“This dish can be found in: A La Carte Menu, Sunday Lunch Menu, Starters, Starters”
How do I limit it to only show the top-level “menus”, like “A La Carte Menu” & “Sunday Lunch Menu”, and stop showing “Starters”, “Main Courses” & “Desserts”
- The topic ‘Limit the results returned by get_the_term_list’ is closed to new replies.