簡體   English   中英

試圖在fontpress主題的標題中添加fontawesome圖標

[英]Trying to add fontawesome icon to header in wordpress theme

我試圖在我的wordpress主題的主標題的左側添加一個圖標,代碼在php中,這就是我不熟悉的東西。 我已經使用filezilla從主題獲取頭文件。 我可以在代碼中的任何地方放入圖標,還是需要在custom-header.php中這樣做? 我嘗試添加的圖標就像這樣<i class="fa fa-cogs"></i>

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">

    <header id="masthead" class="site-header" role="banner">
        <nav id="site-navigation" class="main-navigation" role="navigation">
            <h1 class="menu-toggle"><?php _e( 'Menu', 'padhang' ); ?></h1>
            <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'padhang' ); ?></a>

            <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
        </nav><!-- #site-navigation -->

        <div class="site-branding">

            <?php if ( get_header_image() ) : ?>
                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                    <img class="site-logo" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php bloginfo( 'name' ); ?>">
                </a>
            <?php endif; ?>

            <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        </div>
    </header><!-- #masthead -->

    <div id="content" class="site-content">

很簡單,您需要在主題的function.php文件中加入Font Awesome CSS才能加載它。 並使用fa-icon語法形式在HTML中使用它。

add_action( 'wp_enqueue_scripts', 'enqueue_load_fa' );
function enqueue_load_fa() {
    wp_enqueue_style( 'load-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0 /css/font-awesome.min.css' );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM