如何在wordpress中将标签slug显示为tr类?

如何在wordpress中将标签slug显示为tr类?,wordpress,Wordpress,我使用以下代码将标签从条目中提取到标签类。 如何编辑这段代码,以显示标签slug,而不是全名(我总是只有一个标签在这篇文章)。我需要的不是第一个标签而是第一个标签 <?php // The Query query_posts( array ( 'category_name' => 'best-offer', 'posts_per_page' => -1 ) ); // The Loop while ( have_posts()

我使用以下代码将标签从条目中提取到标签类。 如何编辑这段代码,以显示标签slug,而不是全名(我总是只有一个标签在这篇文章)。我需要的不是第一个标签而是第一个标签

 <?php

      // The Query
      query_posts( array ( 'category_name' => 'best-offer', 'posts_per_page' => -1 ) );

      // The Loop
     while ( have_posts() ) : the_post(); ?>
     <tr class="<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ''; 
}
}
?>">


请尝试使用
$tag->slug
,而不是使用
$tag->name
,如所示