1. 主页
  2. 文档
  3. 搭建一个最简主题
  4. 配置functions.php
  5. 导入css和js

导入css和js

[cc]/**
* Register and Enqueue Styles.
*/
function startwordpress_register_styles() {

$theme_version = wp_get_theme()->get( ‘Version’ );
//导入style.css
wp_enqueue_style( ‘startwordpress-style’, get_stylesheet_uri(), array(), $theme_version );
}
add_action( ‘wp_enqueue_scripts’, ‘startwordpress_register_styles’ );

/**
* Register and Enqueue Scripts.
*/
function startwordpress_register_scripts() {

$theme_version = wp_get_theme()->get( ‘Version’ );

wp_enqueue_script( ‘startwordpress-js’, get_template_directory_uri() . ‘/assets/js/index.js’, array(), $theme_version, false );

}

add_action( ‘wp_enqueue_scripts’, ‘startwordpress_register_scripts’ );[/cc]

对应:

[cc] [/cc]
这篇文章对您有用吗?

我们要如何帮助您?