我正在编辑二十一个主题,但我想更改类别,以便将图标显示为@fontface图标而不是单词。
类别需要看起来像这样(使用艺术类别作为例子):
<a href="THELINKINHERE" rel="category" title="View all categories in Art"><i class="icon-brush"></i></a>
然而,这就是它目前的样子。
<span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span><a href="THELINKINHERE" rel="category" title="View all categories in Art">Art</a>
以下是我的代码:
<?php $show_sep = false; ?>
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) );
if ( $categories_list ):
?>
<span class="cat-links">
<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyeleven' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
$show_sep = true; ?>
</span>
<?php endif;?>
<?php endif; // End if categories ?>
该类需要根据设置的帖子类别进行更改是否有办法手动设置哪个图标链接到哪个类别?
您可以在此处查看我的实时模板http://mhutchinson.me.uk/ 谢谢你的帮助!
梅根
答案 0 :(得分:0)
你可能想尝试这样的事情:
(更改foreach中的打印HTML以满足您的需求)
<?php
foreach((get_the_category()) as $category) {
echo '<img src="http://example.com/images/' . $category->cat_ID . '.jpg" alt="' . $category->cat_name . '" />';
}
?>
干杯