Main.js not loading on custom base.php files

Hi there,

It seems that my main.js isn’t running on my newly created base-form-login.php page yet it works fine on base.php pages.

I’m assuming this is something to with the roots wrapper set up and can’t seem to figure out where it’s going wrong! Any help would be greatly appreciated.

Thank you for your time.

Tom

  • Thought I had solved the issue by changing the file names but still having problems!

What do you mean by “not loading”? Is it in your markup but the file simply isn’t generated? Do you see it in your markup but there’s a 404 error?

Which version of Sage are you using?

What does your custom base file look like?

If main.js is an issue then it’s likely you have other issues too.

Also please be sure you’ve read the templating docs.


1 Like

What I mean is that main.js is correctly being inserted into the html when base.php is being used however when base-login-form.php is used, main.js is not inserted into the html.

My custom base file base-login-form.php looks exactly the same as my base.php except for a single container div.

I’m currently using Sage 8.4.2

Also, have read the docs and unfortunately can’t find anything that helps unfortunately!

Paste your base here please

<?php
use Roots\Sage\Setup;
use Roots\Sage\Wrapper;
?>

<!doctype html>
<html <?php language_attributes(); ?>>
  <?php get_template_part('templates/head'); ?>

  <body <?php body_class(); ?>>

    <div class="container">
      <?php include Wrapper\template_path(); ?>
    </div >

  </body>
</html>

Current base.php content ! Thanks :slight_smile:

Is that the custom base template you’re using which causes main.js to not appear in your markup?

No that’s the base.php file. Below is my custom base template base-form-login.php

<?php
use Roots\Sage\Setup;
use Roots\Sage\Wrapper;
?>

<!doctype html>
<html <?php language_attributes(); ?>>
  <?php get_template_part('templates/head'); ?>

  <body <?php body_class(); ?>>
    <?php include Wrapper\template_path(); ?>
  </body>

</html>

My custom base file base-login-form.php looks exactly the same as my base.php except for a single container div.

They are very different, you have stripped a lot of functionality from the working base template. Have you read this?

Have just tidied up my copy and pasted code so you should notice that in fact the only difference is a container div!

Hope that is slightly clearer

It is not the only difference. You completely stripped out the footer which is where main.js gets called.

2 Likes

Ah shite! That’s the ticket! Forgot to put wp_footer back in! Thank you so much for your help, you’re a legend.