I have two different footers being used on a WordPress site. One is the standard footer.php
the other is for the contact and legal pages and is footer-contact.php
Calling them on the relevant page is straightforward enough - I just a use <?php get_footer('contact'); ?>
on the pages where the contact footer is needed.
This 2nd footer design though isn't calling in the scripts. In my functions.php file I use the following, with the last parameter being 'true' which places the JS in the footer.
wp_enqueue_script('main_js', get_theme_file_uri('/js/main.js'), NULL, '1.0', true);
How do I also enqueue my scripts into the second footer i.e. footer-contact.php
I have two different footers being used on a WordPress site. One is the standard footer.php
the other is for the contact and legal pages and is footer-contact.php
Calling them on the relevant page is straightforward enough - I just a use <?php get_footer('contact'); ?>
on the pages where the contact footer is needed.
This 2nd footer design though isn't calling in the scripts. In my functions.php file I use the following, with the last parameter being 'true' which places the JS in the footer.
wp_enqueue_script('main_js', get_theme_file_uri('/js/main.js'), NULL, '1.0', true);
How do I also enqueue my scripts into the second footer i.e. footer-contact.php
- 1 Do you call the wp_footer() function in your contact footer? – Luckyfella Commented Oct 12, 2019 at 22:29
1 Answer
Reset to default 1While get_footer('name_template_file');
includes the defined footer template it does not output Wordpress wp_enqueued styles and scripts that are defined to be output in the footer automatically. To let your page output all javascript files and stylesheets that supposed to go to the footer call <?php wp_footer(); ?>
at the place you want them to be rendered.
You could consider to place them in you main template (directly before </body>
so there is no need to put them in every single footer template you might include. In most cases it should work fine.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745085707a4610392.html
评论列表(0条)