简体   繁体   English

为图标字体添加带有自定义html的自定义wordpress菜单

[英]Adding custom wordpress menu with custom html for icon fonts

I'm going to be using icon fonts for my social media navigation, but i need some much more custom HTML to implement these for my theme. 我将在社交媒体导航中使用图标字体,但我需要更多自定义HTML才能为主题实现这些字体。 The HTML i need to use looks roughly like this: 我需要使用的HTML大致如下所示:

<a href="#" class="icon-alone">
  <span aria-hidden="true" data-icon="&#x25a8;"></span>
  <span class="screen-reader-text">RSS</span>
</a>

Now, would i be better just manually hard baking this into the theme? 现在,我手动将其烘焙为主题会更好吗? I would like to add some sort of support for changing some icons around to a specific few, but i'm not sure how to best implement this so that i can control what classes are being applied. 我想添加某种支持,以将某些图标更改为特定的几个图标,但是我不确定如何最好地实现这一点,以便我可以控制要应用的类。 I would prefer a section in the admin where i could control them. 我希望在管理员中可以控制它们的部分。 Pointers? 指针?

Thanks. 谢谢。

You could try jquery to do this. 您可以尝试使用jQuery来做到这一点。 There will be an existing class to a wp nav anchor so you can use it. wp导航锚将存在一个现有的类,因此您可以使用它。

<script>
$(function(){
    $("a.menu_class").addClass("icon-alone");
    $("a.menu_class").attr("href","#");     
    $("a.menu_class").html('<span aria-hidden="true" data-icon="&#x25a8;"></span><span class="screen-reader-text">RSS</span>');
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM