Font awesome icons not showing in Wordpress after site address URL change

给你一囗甜甜゛ 提交于 2019-12-23 09:27:36

问题


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?

Many thanks for any help/guidance.

Alison


回答1:


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.

<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.

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' );



回答2:


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.

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.




回答3:


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).

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).

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.




回答4:


Just another idea to throw in here - after transferring the site to the new server, and running this handy script to 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.




回答5:


In my case, I had that problem changing the url using the constants WP_HOME WP_SITEURL at wp-config.php

When I changed through the wp-admin using the RELOCATE flag, worked

As you may know, this is the official doc about it




回答6:


I had this problem so many times but this time I found the full proof solution for this issue:

Open PhpMyAdmin and then click on wp_options table. 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.

The problem might occur due to Http to Https migration 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.



来源:https://stackoverflow.com/questions/39077053/font-awesome-icons-not-showing-in-wordpress-after-site-address-url-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!