与其手动编写标志的html代码,不如使用php和wordpress函数创建:
$countries = get_terms(\'country\', array(\'hide_empty\' => true) );
$exclude_terms = array(\'featured\');
if ( ! empty($countries) && is_array($countries) ) { ?>
<img class="mapAdjust" src="<?php bloginfo(\'template_url\'); ?>/img/map-adjust.gif" />
<img class="map" src="<?php bloginfo(\'template_url\'); ?>/img/map.jpg" />
<?php
foreach ( $countries as $country ) {
if ( ! empty($exclude_terms) && in_array($country->slug, $exclude_terms) ) continue;
$name = esc_attr($country->name);
$slug = $country->slug;
?>
<div class="flag<?php echo str_replace(\' \', \'\', $name); ?>">
<a href="<?php echo get_term_link($country, \'country\') ?>" alt="<?php echo $name; ?>" title="<?php echo $name; ?>">
<img class="flag" src="<?php bloginfo(\'template_url\'); ?>/img/flags/<?php echo $slug; ?>-flag.png" />
</a> <!-- <?php echo $name; ?> -->
</div> <!-- /flagCont -->
<?php
}
}
我只使用了两个函数: