我使用侧栏上的Categories小部件,我想显示Font Awesome icon 在小部件中列出的每个类别旁边。目前,所有类别的图标都是一样的,但我想在将来为每个类别赋予自己独特的图标。
我想使用我的functions.php 通过插入标记添加图标的文件,如<i class="fa fa-chevron-right"></i>
进入类别标题后的类别链接/锚定元素。我可以通过CSS来实现这一点,但这样做的时候,我失去了以编程方式确定要显示哪个图标的能力,以及我希望在将来进行其他改进/更改的灵活性。
基本上,我希望达到这样的效果:
Cat 1 > Cat 2 > Cat 3 >(The greater-than symbol \'>\' represents the icon placement relative to the category title)
我在函数中加入了Font-Awesome。使用wp_enqueue_scripts
钩子如下,它可以完美地加载和显示图标。请注意,我没有使用任何为WordPress构建的字体很棒的插件。
/* Enqueue Scripts
-----------------------------------------------------------------*/
add_action( \'wp_enqueue_scripts\', \'essentials_enqueue_scripts\' );
function essentials_enqueue_scripts() {
/* jQuery */
wp_enqueue_script(\'jquery\');
wp_enqueue_script( \'jquery_ui\', "http" . ($_SERVER[\'SERVER_PORT\'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/2.0.3/jquery-ui.min.js", false, null);
wp_enqueue_script( \'waypoints\', get_template_directory_uri() . \'/js/waypoints.min.js\');
wp_enqueue_script( \'essentials_main\', get_template_directory_uri() . \'/js/essentials_main.js\', array(), \'1.0.0\', true );
wp_enqueue_script( \'essentials_show_stuff\', get_template_directory_uri() . \'/js/essentials_show_stuff.js\', array(), \'1.0.0\', true );
/* Google Fonts */
wp_register_style(\'GoogleFonts\',\'http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Bad+Script\');
wp_enqueue_style( \'GoogleFonts\');
/* Font Awesome Fonts */
wp_register_style(\'Font Awesome\',\'//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css\');
wp_enqueue_style( \'Font Awesome\');
}
尽管我尽了最大的努力,我还是无法找到修改categories小部件的解决方案。