Welcome to my Blog

Lorem ipsum dolor amet conse semper ctetur adipig NOW!

Archive for the ‘WordPress’ category

Selectively Loading JavaScript and CSS Files in WordPress

31 March 2015 - WordPress - James Brown - 1 Comment

If you’ve done any WordPress development, you’ve encountered a situation where you need to load custom JavaScript or CSS. Normally, you would do something like this: function enqueue_scripts_styles() { wp_enqueue_script(‘jquery’); wp_enqueue_script(‘custom-script’, get_stylesheet_directory_uri() . ‘/assets/js/custom.js’, array(‘jquery’)); wp_enqueue_style(‘custom-style’, get_stylesheet_directory_uri() . ‘/assets/css/custom.css’, array() ); } add_action( ‘wp_enqueue_scripts’, ‘enqueue_scripts_styles’ ); This code will load jQuery, then load our custom […]