【问题标题】:Manually setting wordpress categories for fontface Icons手动设置字体图标的 wordpress 类别
【发布时间】:2012-08-20 23:18:43
【问题描述】:

我正在编辑 21 个主题,但我想更改类别,以便它们将图标显示为 @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/ 感谢您的帮助!

梅根

【问题讨论】:

    标签: html wordpress themes font-face categories


    【解决方案1】:

    你可能想尝试这样的事情:

    (更改 foreach 中打印的 HTML 以满足您的需要)

    <?php 
    foreach((get_the_category()) as $category) { 
    echo '<img src="http://example.com/images/' . $category->cat_ID . '.jpg" alt="' .    $category->cat_name . '" />'; 
    } 
    ?>
    

    干杯

    【讨论】:

      猜你喜欢
      • 2016-08-01
      • 2018-09-10
      • 2012-04-12
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多