Answer the question
In order to leave comments, you need to log in
Connect styles for different header?
I’ve been sitting on WordPress for a few days, so don’t scold me, I can’t find information anywhere, I don’t even know how to correctly formulate a request in google ...
The page header page-header.php (For example) uses different styles than home-header .php To include styles on home-header.php, a function like myTheme_assets is used via wp_enqueue_style/script (File fucntion.php), but on home-header it is searched automatically when I use the wp_head function (For footer, also wp_footer) , but how find it and connect it to page-home.php? After all, what is the right way to call this function?
I know function/file names matter a lot, so this question is here too
Answer the question
In order to leave comments, you need to log in
wp_enqueue_scripts
You need to have the same logic for connecting scripts
on the hook , which is used when connecting different header files
function add_theme_scripts() {
if ( is_home() || is_front_page() ) {
wp_enqueue_style( 'slyle-home', get_theme_file_uri( 'assets/css/slyle-home.min.css' ) );
} else {
wp_enqueue_style( 'slyle-page', get_theme_file_uri( 'assets/css/slyle-page.min.css' ) );
}
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question