php – 如何在wordpress主题中包含styles.css?

我试图将styles.css样式表包含在我正在尝试开发的wordpress主题中(我的第一个).问题:如何包含它?我知道将以下代码放在我的header.PHP文件中:

<link rel="stylesheet" href="<?PHP bloginfo('stylesheet_url'); ?>">

但我宁愿通过functions.PHP包含它,如下所示:

<?PHP
function firstTheme_style(){
    wp_enqueue_style( 'core', 'style.css', false ); 
}
add_action('wp_enqueue_scripts', 'firstTheme_style');
?>

然而这根本不起作用(当我从header.PHPs’head’中删除该行时,我的样式没有被看到?

解决方法:

以下方法包括style.css.

方法 – 1

// add in your header.PHP
<link rel="stylesheet" href="<?PHP echo get_stylesheet_uri(); ?>">

方法 – 2

// load css into the website's front-end
function mytheme_enqueue_style() {
    wp_enqueue_style( 'mytheme-style', get_stylesheet_uri() ); 
}
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_style' );

方法 – 3

// Add this code in your functions.PHP
function add_stylesheet_to_head() {
      echo "<link href='".get_stylesheet_uri()."' rel='stylesheet' type='text/css'>";
}

add_action( 'wp_head', 'add_stylesheet_to_head' );

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...