-1

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

0

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

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.

2
  • but how to call css – التقنية tech Aug 7 '20 at 7:32
  • Sorry, I didn't explain that very well on re-reading. So the block of code I supplied will be added to your theme's functions.php file. What this is doing is adding your new stylesheet into the site header, but only for the pages that have your new template set. – Ben Aug 7 '20 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.