最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to laod wp_enqueue_style to another header i created my self

programmeradmin2浏览0评论

How to laod wp_enqueue_style to another header i created my self

name of the header manga-single-reading.php wp_enqueue_style code in wp-manga.php

the code is wp_enqueue_style( 'wp-manga-plugin-css', WP_MANGA_URI . 'assets/css/style.css' );

How to laod wp_enqueue_style to another header i created my self

name of the header manga-single-reading.php wp_enqueue_style code in wp-manga.php

the code is wp_enqueue_style( 'wp-manga-plugin-css', WP_MANGA_URI . 'assets/css/style.css' );

Share Improve this question asked Aug 6, 2020 at 7:24 التقنية techالتقنية tech 133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Wordpress features a very robust template hierarchy that should be observed, take a look at wphierarchy.

If you needed two header formats for some reason, you could create a file in the theme root called header-manga.php which you could then call in your page template with <?php get_header( 'manga' ); ?>.

Once you have your new header set-up you could create a custom page template like page-mymanga.php which calls the manga header as above.

Once you have this, you can then set the page(s) you want to use this header to have the page template of page-mymanga.php using the WP control panel, and then use a function in your themes functions.php file that might look like this:

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' );
    } 
}

If you're working in a theme from the marketplace I would strongly recommend looking into making a child theme before making any edits to the theme file. If you make changes to the parent, any future version updates will overwrite your updates.

发布评论

评论列表(0)

  1. 暂无评论