Skip to content

Instantly share code, notes, and snippets.

@sudipbd
Last active November 19, 2016 08:06
Show Gist options
  • Select an option

  • Save sudipbd/c350809aecca5eb80e62d95f40be3b04 to your computer and use it in GitHub Desktop.

Select an option

Save sudipbd/c350809aecca5eb80e62d95f40be3b04 to your computer and use it in GitHub Desktop.
WordPress style and script enqueue
<?php
function ah_scripts(){
//register style
wp_register_style( 'ah-bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.37', 'all' );
wp_register_style( 'ah-slicknav', get_template_directory_uri() . '/css/slicknav.min.css', array(), '1.0.10', 'all' );
wp_register_style( 'ah-font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.5', 'all' );
wp_register_style( 'ah-google-font', 'https://fonts.googleapis.com/css?family=Titillium+Web:400,700,900', array(), '0.1', 'all' );
//enqueue style
wp_enqueue_style( 'ah-bootstrap' );
wp_enqueue_style( 'ah-slicknav' );
wp_enqueue_style( 'ah-font-awesome' );
wp_enqueue_style( 'ah-google-font' );
//enqueue main stylesheet
wp_enqueue_style( 'ah-style', get_stylesheet_uri() );
//register script
wp_register_script('ah-modernizr', get_template_directory_uri() . '/js/vendor/modernizr-2.8.3.min.js', array(), '2.8.3', false);
wp_register_script('ah-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.37', true);
wp_register_script('ah-slicknav', get_template_directory_uri() . '/js/jquery.slicknav.min.js', array(), '1.0.10', true);
wp_register_script('ah-main', get_template_directory_uri() . '/js/main.js', array(), '0.1', true);
wp_register_script('ah-jq', get_template_directory_uri() . '/js/vendor/jquery-1.12.0.min.js', array(), '1.12.0', true);
wp_enqueue_script('ah-jq');
//enqueue script
wp_enqueue_script('ah-modernizr');
wp_enqueue_script('ah-bootstrap');
wp_enqueue_script('ah-slicknav');
wp_enqueue_script('ah-main');
}
add_action('wp_enqueue_scripts', 'ah_scripts');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment