如何将wp_enqueue_style添加到我自己创建的另一个标头
wp-manga.php中标头manga单读. the wp_enqueue_style代码的名称
代码是wp_enqueue_style(‘WP_MANGA_URI plugin’,WP_MANGA_URI)。“资产/css/style.css”);
发布于 2020-08-06 22:09:27
Wordpress提供了一个非常健壮的模板层次结构,它应该被观察到,看看wphierarchy.com。
如果出于某种原因需要两种头格式,可以在主题根header-manga.php中创建一个文件,然后使用<?php get_header( 'manga' ); ?>调用页面模板。
一旦您设置了新的标题,您就可以创建像page-mymanga.php这样的自定义页面模板,该模板调用上面的manga标题。
有了这个之后,您就可以使用这个标题设置页面(S),使用WP控制面板获得page-mymanga.php的页面模板,然后在主题functions.php文件中使用如下所示的函数:
add_action('wp_enqueue_scripts','load_custom_template_script');
function load_custom_template_script(){
if ( is_page_template('page-mymanga.php') ) {
wp_enqueue_style( 'wp-manga-plugin-css', get_template_directory_uri() . '/assets/css/style.css' );
}
}https://wordpress.stackexchange.com/questions/372460
复制相似问题