This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

How to properly add a js file

  • Creator
    Topic
  • #7569
    littleantz
    Participant

    Hi,

    I want to add a js file and stylesheet. How do I do that properly so I keep the changes even after update?

    Currently I am using child theme and presumably I added my css like this from the functions.php

    themeblvd_add_stylesheet( 'custom_styles', get_stylesheet_directory_uri().'/assets/css/my_style.css', 5 );

    I want to add a js script also. Can you give me a sample of how to do it?

    Thanks

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #7576
    Jason Bobich
    Keymaster

    Hello,

    There’s nothing really specific to the theme you need to know. You’d just enqueue it as normal.

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Here’s a basic example, taking into account how the default Child theme we provide is setup.

    function my_scripts() {
    	wp_enqueue_script(
    		'your-custom-script',
    		get_stylesheet_directory_uri() . '/assets/js/whatever.js'
    	);
    	// add any other scripts you want here also ...
    }
    add_action( 'wp_enqueue_scripts', 'my_scripts' );
Viewing 1 replies (of 1 total)
  • The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.