将此简单支票添加到foreach
循环:
<?php
$categories = get_the_category();
foreach($categories as $cat):
if ( $cat->name == \'Media\' ) continue;
?>
<a href="<?php echo get_category_link($cat->term_id); ?>">
<?php echo $cat->name; ?>
</a>
<?php endforeach; ?>
您可以对照类别列表检查类别名称:
<?php
$categories = get_the_category();
foreach($categories as $cat):
if ( in_array( $cat->name, array( \'Media\', \'Other Category 1\', \'Other Category 2\' ) ) ) continue;
?>
<a href="<?php echo get_category_link($cat->term_id); ?>">
<?php echo $cat->name; ?>
</a>
<?php endforeach; ?>