0
Welcome Guest! Login
0 items Join Now

Adding javascript files to Gantry index.php header

  • Adding javascript files to Gantry index.php header

    Posted 4 years 6 months ago
    • What is the method for including javascript files in the Gantry header, which won't be overwritten with a gantry/template update?

      For a normal wordpress template, I would create a child theme and override index.php. But I can't see how to create a child theme of gantry because of the dynamic way css files are created by the LESS compiler. If there is a way then please let me know!
    • Freshpage Web Design
  • Re: Adding javascript files to Gantry index.php header

    Posted 4 years 6 months ago
    • Hi,

      You can add your custom javascipt files under theme's js folder and then call the addScript method of the global $gantry object:
          
      global $gantry;
      $gantry->addScript( 'customscript.js' );

      You can add the code above in index.php of the theme or in a widget in the page you want to use your js.

      Hope this helps :D
    • Posting a url to your site and screenshots of your issue could be really helpful.
      How to add a Custom Stylesheet in Gantry for WP
  • Re: Adding javascript files to Gantry index.php header

    Posted 4 years 6 months ago
    • Adding to index.php would be overwritten when the gantry theme is updated wouldn't it?

      Maybe I could put it in a widget but that seems a bit of a hack.
    • Freshpage Web Design
  • Re: Adding javascript files to Gantry index.php header

    Posted 4 years 6 months ago
    • Hi,

      Theme's index.php isn't affected by Gantry updates but only with theme updates and is one of the least changed files.

      Another way would be to use a plugin that will load automatically your js. Here is one, but i haven't tested so i can't predict the results.

      Hope this helps :D
    • Posting a url to your site and screenshots of your issue could be really helpful.
      How to add a Custom Stylesheet in Gantry for WP
  • Re: Adding javascript files to Gantry index.php header

    Posted 6 months 2 weeks ago
    • Almost four years on from this activity, is there any better way to include a js file short of creating a new particle in G5?

      Paula
    • Do'er of stuff

Time to create page: 0.242 seconds