0

I have two different footers being used on a WordPress site. One is the standard footer.phpthe 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
  • 1
    Do you call the wp_footer() function in your contact footer? – Luckyfella Oct 12 '19 at 22:29
1

While 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.

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.