站点地址 URL 更改后,字体真棒图标未显示在 Wordpress 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39077053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Font awesome icons not showing in Wordpress after site address URL change
提问by AlisonDesign
This may be an obvious question for those of you more advanced in coding than myself...but I created a website in WordPress but their domain is hosted elsewhere. They changed the A name and it now points to the site, but the font awesome icons are now square boxes. How can I fix this? Is there a simple way?
对于那些在编码方面比我更先进的人来说,这可能是一个明显的问题……但是我在 WordPress 中创建了一个网站,但他们的域托管在其他地方。他们更改了 A 名称,现在它指向该站点,但是字体真棒图标现在是方形框。我怎样才能解决这个问题?有没有简单的方法?
Many thanks for any help/guidance.
非常感谢任何帮助/指导。
Alison
艾莉森
回答by Owais Alam
This is the easiest one. All you have to do is add this single line of code in your theme's header.php file just before the tag.
这是最简单的一种。您所要做的就是在主题的 header.php 文件中的标记之前添加这一行代码。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
This method is simplest, but it can cause conflicts with other plugins. A better approach to load stylesheets or scripts in WordPress is to properly enqueue them. Instead of linking to the stylesheet from your theme's header template, you can add the following code in your theme's functions.php file or in a site-specific plugin.
这种方法最简单,但会导致与其他插件冲突。在 WordPress 中加载样式表或脚本的更好方法是正确地将它们排入队列。您可以在主题的functions.php 文件或特定于站点的插件中添加以下代码,而不是从主题的标题模板链接到样式表。
function wpb_load_fa() {
wp_enqueue_style( 'wpb-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' );
}
add_action( 'wp_enqueue_scripts', 'wpb_load_fa' );
回答by Pankaj Kumar
Fix the problem in less then 2 mins. Simple replacement of /font-awesome/5.13.0/css/fontawesome.min.css with /font-awesome/5.13.0/css/all.min.css and also font-awesome/5.13.0/js/fontawesome.min.js with /font-awesome/5.13.0/js/all.min.js can fix this issue. https://youtu.be/_GV_pEmLCLU
在不到 2 分钟的时间内解决问题。用 /font-awesome/5.13.0/css/all.min.css 和 font-awesome/5.13.0/js/fontawesome 简单替换 /font-awesome/5.13.0/css/fontawesome.min.css。 min.js 和 /font-awesome/5.13.0/js/all.min.js 可以解决这个问题。https://youtu.be/_GV_pEmLCLU
回答by Steve Ferreiro
Super late, but hopefully this saves someone a lot of time. After migrating an existing Wordpress site to a new domain, I too encountered icons missing (both on the front-end and the back-end administration). After a long search and applying different methods, I found the database still listed the original/old domain within the "option" table.
超级晚了,但希望这可以为某人节省很多时间。将现有的 Wordpress 站点迁移到新域后,我也遇到了图标丢失的情况(前端和后端管理)。经过长时间的搜索和应用不同的方法,我发现数据库仍然在“选项”表中列出了原始/旧域。
Using phpMyAdmin, select the "option" table. Within "option" you will see the "site" and "home" rows. If the value has the old domains, you will need to change it to match the sites URLs (Located on the Administration dashboard under Settings > WordPress Address (URL) & Site Address (URL). To change the value, click Edit > and update the URL.
使用 phpMyAdmin,选择“选项”表。在“选项”中,您将看到“站点”和“主页”行。如果该值具有旧域,您将需要更改它以匹配站点 URL(位于设置 > WordPress 地址 (URL) 和站点地址 (URL) 下的管理仪表板上)。要更改值,请单击编辑 > 并更新网址。
回答by Jon Koeter
I know this is 2 years old, but I just ran into a similar problem and the answer given by Owais did not feel right to me (getting CSS from another site).
我知道这是 2 岁,但我刚刚遇到了类似的问题,Owais 给出的答案对我来说并不合适(从另一个站点获取 CSS)。
This happened to me for the exact same reason as it did for OP. I migrated my website to another host and another domain-name. After doing that I ran a rename-script for the DB (thousants of hard-coded URLs were replaced).
这发生在我身上的原因与 OP 完全相同。我将我的网站迁移到另一个主机和另一个域名。这样做之后,我为数据库运行了一个重命名脚本(替换了数千个硬编码的 URL)。
However, as it turns out, my theme was also using hard-coded URLs in the CSS files and in some JS files, as they were generated (upload/fusion-scripts and upload/fusion-styles). After replacing the hardcoded URLs in these files (I used visual studio, but you can use any bulk-replace tool) everything worked fine again.
然而,事实证明,我的主题还在 CSS 文件和一些 JS 文件中使用了硬编码的 URL,因为它们是生成的(上传/融合脚本和上传/融合样式)。替换这些文件中的硬编码 URL 后(我使用了 Visual Studio,但您可以使用任何批量替换工具),一切又正常了。
回答by resedasue
Just another idea to throw in here - after transferring the site to the new server, and running this handy scriptto replace all references of the old url with the new one, I was still having the same issue with font awesome. The solution was to go to Settings / General and set the Endurance Cache to Off (0). Refreshed the site and all was well.
在这里提出的另一个想法 - 在将站点转移到新服务器并运行这个方便的脚本以将旧 url 的所有引用替换为新的引用后,我仍然遇到相同的字体真棒问题。解决方案是转到“设置”/“常规”并将“耐力缓存”设置为“关闭”(0)。刷新了网站,一切都很好。
回答by José
In my case, I had that problem changing the url using the constants WP_HOME WP_SITEURL at wp-config.php
就我而言,我在使用 wp-config.php 中的常量 WP_HOME WP_SITEURL 更改 url 时遇到了这个问题
When I changed through the wp-admin using the RELOCATE flag, worked
当我使用 RELOCATE 标志通过 wp-admin 进行更改时,工作
As you may know, this is the official docabout it
您可能知道,这是关于它的官方文档
回答by Mayank Yadav
I had this problem so many times but this time I found the full proof solution for this issue:
我多次遇到这个问题,但这次我找到了这个问题的完整证明解决方案:
Open PhpMyAdminand then click on wp_optionstable. In this, you will see a table with a name(according to your theme name) something like "theme_options_css"edit it and change the URL from old to new.
打开phpMyAdmin的,然后点击wp_options表。在此,您将看到一个名称(根据您的主题名称)的表格,例如“theme_options_css”,编辑它并将 URL 从旧更改为新。
The problem might occur due to Http to Httpsmigration also. So for that also change Http to Https manually in the same table and the problem will be resolved the moment you save your table.
该问题也可能由于Http 到 Https 的迁移而发生。因此,为此还要在同一个表中手动将 Http 更改为 Https,并且在您保存表时问题将得到解决。