我的新网站有点困难。
2 确实有问题。
首先是调用外部 JS 和 CSS 脚本。我以与我所有其他网站相同的方式将它们添加到我的functions.php
文件中,它们似乎没有加载
另一个是我的子主题 CSS。它似乎加载在主页上,但在我的自定义页面(到目前为止只做了一个)上它没有加载。我在检查元素时检查了源选项卡,但未显示。
来自 functons.php 的外部脚本和 CSS 代码:
function external_load_scripts() {
wp_register_script( 'popper', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' array('jquery'),'1.14.7', true );
wp_enqueue_script( 'popper' );
wp_register_script( 'bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' array('jquery'),'4.3.1', true );
wp_enqueue_script( 'bootstrap' );
wp_register_script( 'datatables', 'https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js' array('jquery'),'1.10.12', true );
wp_enqueue_script( 'datatables' );
wp_register_script( 'chosen', 'https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.min.js' array('jquery'),'1.4.2', true );
wp_enqueue_script( 'chosen' );
wp_register_script( 'select', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js' array('jquery'),'4.0.0', true );
wp_enqueue_script( 'select' );
}
add_action('wp_enqueue_scripts', 'external_load_scripts');
function external_load_styles() {
wp_register_style( 'chosencss', 'https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.min.css' );
wp_enqueue_style( 'chosencss' );
wp_register_style( 'selectcss', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css' );
wp_enqueue_style( 'selectcss' );
wp_register_style( 'bootstrapcss', 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' );
wp_enqueue_style( 'bootstrapcss' );
wp_register_style( 'allcss', 'https://use.fontawesome.com/releases/v5.0.13/css/all.css' );
wp_enqueue_style( 'allcss' );
wp_register_style( 'datatablescss', 'https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css' );
wp_enqueue_style( 'datatablescss' );
}
add_action('wp_enqueue_scripts', 'external_load_styles');
在functions.php中注册子主题style.css
add_action( 'wp_enqueue_scripts', 'Eazy_Enqueue_styles' );
function Eazy_Enqueue_styles() {
$parent_style = 'minimal-blocks-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
如前所述,子 style.css 似乎适用于主页,但不适用于我使用自定义模板设计的自定义页面
解决这个问题的任何帮助都会很棒。提前致谢