我有一个很简单的问题我解决不了。我为我的卡片定制了样式,卡片的元素之一是类别,当我从循环中访问\\u category()时,它有自己的奇怪样式(看起来像列表项锚定)。我想在while循环中获取类别的url和类别的名称,我的代码如下所示:
<div class="container body-margin">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="card">
<div class="row">
<?php $url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), \'thumbnail\' ); ?>
<img src="<?php echo $url ?>" class="img-responsive card-image" />
</div>
<div class="row card-body">
<div><a class="card-body-category" href="#the-category-url"><?php the_category(); ?></a></div>
<div><h4 class="card-body-title"><b><?php the_title(); ?></b></h4></div>
<div><p class="card-body-date"><?php the_date(); ?></p></div>
</div>
</div>
<?php endwhile; ?>
</div>
我看到的大多数解决方案都是让人们使用get\\u the\\u category()函数在while循环之外访问他们的标签,这不适合我想做的,如果有任何帮助,我将不胜感激。