• Hi there … I am trying to get only top level terms from hierarchical taxonomy called “City”. It works fine in a way, but it outputs extra elements…

    <ul> <?php
    $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:

    <ul>
            <li> ... correct data about term 1 </li>
            <li>
    
            </li>
            <li> ... correct data about term 2 </li>
            <li>
    
            </li>
    </ul>
  • The topic ‘Parent terms returns empty markup’ is closed to new replies.