问题描述
美好的一天,
我已经设置了一个 WordPress 网站并选择了一个主题 (Metrolo) 和 WooCommerce.菜单项应该有一个向下箭头 (\f0d7) 我认为这是由主题设置的.箭头没有显示,只有一个空框.
I've setup a WordPress website and selected a theme (Metrolo) plus WooCommerce. The menu items should have a down arrow (\f0d7) I think this is set by the theme. The arrow is not showing, only an empty box.
我检查了 css 并看到了这个:
I inspect the css and see this:
.sf-menu.sf-arrows .sf-with-ul:after {
font-family: FontAwesome;
font-weight: normal;
font-style: normal;
text-decoration: inherit;
speak: none;
-webkit-font-smoothing: antialiased;
vertical-align: middle;
content: "\f0d7";
float: right;
margin-left: 5px;
}
到目前为止,我所读到的似乎不是主题或 WordPress,而是托管问题.
What I've read so far is that it doesn't seem to be the Theme or WordPress but an hosting issue.
我对网站后端的唯一访问权限是通过 cpanel.
The only access I have to the back-end of the site is via a cpanel.
推荐答案
根据我们的评论,font-awesome
样式表似乎尚未在您的网站上排队.
Based on our comments, it seems that the font-awesome
stylesheet has not been enqueued on your website.
您可以通过主题文件或自定义插件自行排队来轻松纠正此问题:
You can easily rectify this by enqueuing it yourself either through the theme files, or a custom plugin:
在您的functions.php文件中添加以下几行:
Add the following lines in your functions.php file:
add_action( 'wp_enqueue_scripts', 'so_my_custom_scripts' );
function so_my_custom_scripts() {
wp_enqueue_style( 'llt-google-fonts', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css?ver=4.9.6' );
}
通过自定义插件排队:
如果您无权访问您的functions.php文件,或者您没有使用子主题并且不愿意冒险将其添加到您的主主题中,您可以随时添加自己的插件以将其排入队列你.
Enqueuing through a custom plugin:
If you don't have access to your functions.php file, or you aren't using a child theme and are not willing to risk adding this in your main theme, you could always add your own plugin to enqueue it for you.
将以下代码添加到名为 mcfae
的文件夹中名为 mcfae.php
的空白 php 文件中,并通过 ftp 将该文件夹上传到您的插件目录,或将文件夹并从插件仪表板中上传.
Add the following to code to a blank php file named mcfae.php
inside a folder named mcfae
and upload that folder to your plugin directory via ftp, or zip the folder and upload from within the plugin dashboard.
<?
/*
Plugin Name: My Custom Font Awesome Enqueuer
Plugin URI: https://stackoverflow.com/a/50832019/6049581
Description: Ensures that Font Awesome is enqueued.
Version: 1.0.0
Text Domain: mcfae
Author: TungstenX
Author URI: https://stackoverflow.com/a/50832019/6049581
*/
add_action( 'wp_enqueue_scripts', 'mcfae_enqueue_scripts' );
function mcfae_enqueue_scripts() {
wp_enqueue_style( 'llt-google-fonts', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css?ver=4.9.6' );
}
这篇关于WordPress 不显示字体图标 \f0d7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!