Support » Plugins » Hacks » Multiple taxonomies – A more elegant solution?

  • Hi guys,

    I am listing taxonomy terms belonging to a post, only if they exist. So for each taxonomy I am repeating the code below, swapping out the first line as I go. As I have 5 or 6 taxonomies, doing this seems slightly verbose! I am wondering if anyone knows of a more elegant solution?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Create an array like so:
    $taxonomies = array('film','actor','director',//etc...);

    Then wrap your code in a foreach loop:

    foreach($taxonomies as $taxonomy) {
      //your code here

    You’ll also need to do some string manipulation so the h3 title is mixed case and plural. Echo out the result in PHP instead of hard coding the HTML string.

    Perfect. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple taxonomies – A more elegant solution?’ is closed to new replies.