【问题标题】:Remove link around category and tags in Genesis template删除Genesis模板中类别和标签周围的链接
【发布时间】:2017-08-29 08:33:20
【问题描述】:

我想删除博客模板和 Genesis 中的单个模板中的链接(标签)。 我只想显示简单的类别名称和标签,而不需要指向类别的链接。

<p class="entry-meta">    
    <span class="entry-categories">    
       <a href="domain.com/category/category-name/" rel="category tag">Categoryname</a>  
     </span> 
 </p>

所以我想删除a标签。

我在 Genesis 中找不到如何做到这一点。我知道函数“genesis_post_meta”,但我只能更改文本和分隔符。

【问题讨论】:

    标签: wordpress genesis


    【解决方案1】:

    你可以使用 css 来做到这一点

    <p class="entry-meta">
        <span class="entry-categories">
          <a href="domain.com/category/category-name/" rel="category tag"> Categoryname</a>
        </span>
    </p>
    

    在 css 中使用这个

        .entry-categories a {pointer-events: none;cursor: default;}
    

    也检查一下 http://jsfiddle.net/7EQJp/

    【讨论】:

    【解决方案2】:

    我在http://elektroelch.net/wordpress-remove-links-from-the-category/ 上找到了这个:

    add_filter( 'the_category', 'no_links' );
          function no_links($thelist) {
            return preg_replace('#<a.*?>([^<]*)</a>#i', '$1', $thelist);
     }
    

    函数 no_links() 包含一个从字符串中删除所有锚点的正则表达式。这就是全部技巧。在您的代码末尾,您应该再次删除过滤器,以防类别以标准样式显示在同一页面上。

    【讨论】:

      【解决方案3】:

      正确的方法是使用过滤器

      remove_filter( 'the_category', 'no_links' 10,1 );
      or
      add_filter( 'the_category', 'no_links' );
      

      这里是完整的例子:https://themerevel.com/tutorials/wordpress-how-to-remove-category-from-your-urls/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-10-18
        • 1970-01-01
        • 2015-10-14
        • 1970-01-01
        • 1970-01-01
        • 2015-07-02
        • 2015-04-09
        相关资源
        最近更新 更多