php如何在wordpress中加载fontawesome5(代码片段)

author author     2022-12-11     512

关键词:

.entry-content ul.nav 
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    margin-left: 0;


.entry-content ul.nav > li 
    margin-right: 30px;
    list-style-type: none;


.entry-content ul.nav > li:last-child 
    margin-right: 0;


ul.nav li a 
    color: #333;
    text-decoration: none;


ul.nav .svg-inline--fa 
    margin-right: 8px;
<ul class="nav">
    <li class="home"><a href="#"><i class="fas fa-home"></i>Home</a></li>
    <li class="about"><a href="#"><i class="fas fa-info-circle"></i>About</a></li>
    <li class="contact"><a href="#"><i class="fas fa-envelope"></i>Contact</a></li>
</ul>
An alternative method is to simply paste

Copy to clipboard
<script defer src="https://use.fontawesome.com/releases/v5.0.1/js/all.js"></script>

in your theme’s settings page in the Header section (if such an option is present).

https://fontawesome.com/how-to-use/svg-with-js has comprehensive info on how to use the new Font Awesome 5.
// https://sridharkatakam.com/load-font-awesome-5-wordpress/
// Font Awesome 5 was released 2 days ago. The main way of loading it has changed from a CSS file to a JS file with the move away from icon fonts to SVG.

// Font Awesome 5 has been recently released with SVG vector icons compared to the earlier icon fonts.

// To load Font Awesome 5+’s “SVG with JS” in your WordPress site, add the following in the active theme’s functions.php:

// Enqueue Font Awesome.
add_action( 'wp_enqueue_scripts', 'custom_load_font_awesome' );
function custom_load_font_awesome() 
    wp_enqueue_script( 'font-awesome', 'https://use.fontawesome.com/releases/v5.0.1/js/all.js', array(), null );


add_filter( 'script_loader_tag', 'add_defer_attribute', 10, 2 );
/**
 * Filter the HTML script tag of `font-awesome` script to add `defer` attribute.
 *
 * @param string $tag    The <script> tag for the enqueued script.
 * @param string $handle The script's registered handle.
 *
 * @return   Filtered HTML script tag.
 */
function add_defer_attribute( $tag, $handle ) 
    if ( 'font-awesome' === $handle ) 
        return str_replace( ' src', ' defer src', $tag );
    


// Replace 5.0.1 with the current latest version which can be seen at https://fontawesome.com/get-started/svg-with-js. This applies to the rest of the article as well.

如何在 Wordpress 中加载 Ajax

】如何在Wordpress中加载Ajax【英文标题】:HowtoLoadAjaxinWordpress【发布时间】:2013-07-1615:38:41【问题描述】:我熟悉用jQuery以普通方式使用ajax。我已经玩了一段时间了,但不明白Wordpress需要什么才能让它工作......我这里的内容来自... 查看详情

如何在 Wordpress 插件中加载 Javascript

】如何在Wordpress插件中加载Javascript【英文标题】:howtoloadJavascriptinWordpressPlugin【发布时间】:2012-02-2620:27:01【问题描述】:谁能告诉我如何将此javascript文件包含到我的wordpress插件中。我已经尝试了所有wp_enqeue_script()方法,但没... 查看详情

php在wordpress中加载css(代码片段)

查看详情

php在php/wordpress中加载主题元素(代码片段)

查看详情

php在wordpress中加载javascript库(代码片段)

查看详情

php在wordpress生成的页面中加载javascript库(代码片段)

查看详情

我如何在我的 wordpress 主题头标签中加载 CSS 文件 [重复]

】我如何在我的wordpress主题头标签中加载CSS文件[重复]【英文标题】:HowicanloadaCSSfileinmywordpressthemeheadtag[duplicate]【发布时间】:2016-10-2623:47:08【问题描述】:我是WordPress新手。我有一个链接,我想在我的WordPress主题的head标签中... 查看详情

ajax在WordPress中加载页面后如何触发jquery插件?

】ajax在WordPress中加载页面后如何触发jquery插件?【英文标题】:HowtotriggerjquerypluginsafterajaxhasloadedapageinWordPress?【发布时间】:2012-06-2515:24:14【问题描述】:在Google搜索结果中的所有链接都是紫色的并且我很沮丧几个小时后,我... 查看详情

在中加载特定的javascript文件标题.php仅在主页中?在wordpress中

Inyourheader.phpfile:<?phpif(is_front_page()):?><?php/*?>yourjavascriptcode<?php*/?><scripttype=”text/javascipt”src=”yourfile.js”></script><?ph 查看详情

jQuery插件未在WordPress中加载

】jQuery插件未在WordPress中加载【英文标题】:jQuerypluginnotloadinginWordPress【发布时间】:2013-08-2113:08:58【问题描述】:我已经在functions.php中成功地将jQuery链接到WordPress。但是,center.js似乎没有加载。我这么说是因为控制台给了我... 查看详情

在wordpress中加载jquery

<?phpwp_enqueue_script("jquery");?> 查看详情

phpjquery在wordpress中加载最新版本(代码片段)

查看详情

如果管理员登录,则在 WordPress 中加载不同的样式表

】如果管理员登录,则在WordPress中加载不同的样式表【英文标题】:LoadadifferentstylesheetinWordPressifanadminisloggedin【发布时间】:2013-08-1604:21:06【问题描述】:我希望能够在我的主题中放置一个条件PHP代码,当管理员或只有一个用户... 查看详情

在 WordPress 中加载模板而不回显它

】在WordPress中加载模板而不回显它【英文标题】:LoadtemplateinWordPresswithoutechoit【发布时间】:2013-09-2805:47:09【问题描述】:我正在尝试编写一个自定义函数,以在单独的div中加载一组产品,以便在选项卡中使用。每个选项卡都有... 查看详情

如何使用 NGINX、PHP-FPM 在 docker-compose.yml 文件中加载 mysqli 扩展

...】:2019-11-2720:59:16【问题描述】:加载docker-composeup时,wordpress在url上加载,但mysqli_connect函数未定义,因为没有 查看详情

在 WordPress 中加载更多帖子 Ajax 按钮

】在WordPress中加载更多帖子Ajax按钮【英文标题】:LoadMorePostsAjaxButtoninWordPress【发布时间】:2015-10-1317:59:39【问题描述】:我浏览了旧问题并尝试了许多似乎可以做到这一点的不同方法。我最接近工作的是这里:Howtoimplementpaginati... 查看详情

在wordpress生成的页面中加载javascript库

LoadjQueryintoWordPressgeneratedpages,thewp_enqueue_scriptfunctioncanbeusedinpluginsaswell.ORAddandloadanewscriptthatdependsonjQuery(thiswillalsocauseittoloadjQueryintothepageaswell).<?phpwp_enqueu 查看详情

WordPress/Avada 网站未在 XAMPP 中加载

】WordPress/Avada网站未在XAMPP中加载【英文标题】:WordPress/AvadawebsitenotLoadinginXAMPP【发布时间】:2017-05-1016:45:24【问题描述】:所以我一直在尝试进入一个我应该在工作的WordPress网站的管理仪表板,但由于某种原因,我的XAMPP/phpMyAd... 查看详情