Categories
WordPress WordPress Templates

Underscores Menu Exercise pt 3: Enqueuing Scripts

Other Values

If enqueueing scripts (or local stylesheets), it is a bit more complicated, but it’s learnable.

All URLs in WordPress are absolute, not relative, so when the theme is installed at a new domain, WordPress needs to figure out the path to resources, starting with the https://domain.com/ part.

If you look at the script enqueueing, you will see that this is done with the php concatenation operator (the dot). The get_template_directory() function retrieves the absolute URL of the theme, then we add the dot, then the remainder of the path to the local script.

The remaining values passed to the function are:

  • An Array: if needed we can list script dependencies here, by their handles. Don’t worry about that for now.
  • A number, typically today’s date, that will be appended to the URL for cache busting purposes. Don’t worry about that either
  • True or False: this determines whether the script loads in the before the close of the BODY rather than in the head of the page. True = bottom of page; False = header. Because our icons need to load quickly, we will load them in the header, so we set that value to false.

MORE TO DO ON THIS.