0

I am trying to get only top level terms from hierarchical taxonomy called "City". It works fine in a way, because it outputs extra elements...

        $cities = get_terms( 'city' , array(
                  'parent'     => 0,
                  'orderby'    => 'name',
                  'order'      => 'ASC',
                  'hide_empty' => true
                   ));
        foreach ($cities as $city) { ?>
        <li><a href="<?php echo get_term_link( $city, 'city' ); ?>" class="button radius"><?php echo $city->name; ?></a><li>
        <?php } ?>
       </ul>

Which retuns only 2 cities (and each of them has several child terms) The returned HTML looks like this:

    <li> ... correct data about term 1 </li>
    <li>

    </li>
    <li> ... correct data about term 2 </li>
    <li>

    </li>
    </ul>

1 Answer 1

0

check your closing

  • your missing the close. It should be

    <li><a href=""></a></li> 
    
  • 2
    • Many thanks ... It was kind of stupid mistake of mine not to see it, but in the end I missed it :) Again thank you ...
      – kmavrov
      Oct 11, 2014 at 14:25
    • many of us have done it look saat the same block for ages, then a fresh pair of eyes just spot it like that Oct 12, 2014 at 12:40

    Not the answer you're looking for? Browse other questions tagged or ask your own question.