Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #1766842
Add custom code (HTML, JS)
Closed

Comments

  • legalcalls started the conversation

    Hi,

    How can I add custom code (HTML, JS) to my site? I'd be interested to add it site-wide, but on individual pages would also work.

    Thank you!

  •  7,095
    Oliver replied

    Hi,

    You need to use child theme to add it, take a look:

    http://codex-themes.com/thegem/documentation/css

    Child theme in attach

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • legalcalls replied

    I'm using the child theme, but isn't the Custom CSS for CSS only?

  •  7,095
    Oliver replied

    Example:

    function theme_js() {
        wp_enqueue_script( 'theme_js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.0', true );
    }
    add_action('wp_enqueue_scripts', 'theme_js');
    

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • legalcalls replied

    Thanks, but I'm not sure what that code is for. So to be clear, the Custom CSS capability also works for HTML & JS? It's not just for CSS, right?

  •  7,095
    Oliver replied

    Hi,

    All the css changes should be done in the style.css of the child theme.

    If you need to add your custom.js code, use my function to connect custom.js file in the child theme, (so you need to add the file /js/custom.js and put your JS code there)

    Or you can use Custom CSS filed and Custom JS field in the theme options, here:

     

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • legalcalls replied

    Ah, didn't see the Custom JS field there, my bad. Thank you!

  •  7,095
    Oliver replied

    You're welcome!

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver