M
M
M_Mariya2021-07-29 14:29:11
WordPress
M_Mariya, 2021-07-29 14:29:11

Different header on different pages - how to include different styles in function.php?

there is a landing page - it's the main one.
it has its own template - front-page.php
and its own header - header-main.php,
and its own footer - footer-main.php :

this option includes everything in the usual header.php and footer.php.

if ( is_page_template( 'front-page.php' )) ​​{
//include style
wp_enqueue_style( 'my-main-style', get_template_directory_uri() . '/src/css/style.css', array(), '1.0' );
//include the script
wp_enqueue_script('my-main-js', get_template_directory_uri() . '/src/js/script.js', array(), true, true);
}

Including header-main.php and footer-main.php in the front-page.php template itself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-07-30
@artzolin

Use the conditional tag is_front_page(), it checks that the main (home) page of the site is displayed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question