Page Specific CSS and JS in wordpress

Page Specific CSS and JS in wordpress
function hollycross_scripts() {

wp_enqueue_style( 'clndrcss', get_template_directory_uri() . '/css/clndr.css', array(), _S_VERSION );	
wp_enqueue_style( 'pathways-style', get_stylesheet_uri(), array(), _S_VERSION );
wp_style_add_data( 'pathways-style', 'rtl', 'replace' );

wp_enqueue_style( 'slick-style', get_template_directory_uri() . '/app/css/slick.css', array(), _S_VERSION );
wp_enqueue_style( 'aos-style', get_template_directory_uri() . '/app/css/aos.css', array(), _S_VERSION );
wp_enqueue_style( 'select2-style', get_template_directory_uri() . '/app/css/select2.css', array(), _S_VERSION );
wp_enqueue_style( 'font-awesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), _S_VERSION );
wp_enqueue_style( 'googleapis', 'https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap', array(), _S_VERSION );

$style_css_path = get_template_directory().'/app/css/style.min.css';
$style_css_ver  = filemtime( $style_css_path );

wp_enqueue_style( 'style-min', get_template_directory_uri() . '/app/css/style.min.css', array(), $style_css_ver  );

wp_enqueue_style( 'style-main', get_template_directory_uri() . '/app/css/style-main.css', array(), $style_css_ver  );


wp_deregister_script('jquery');

wp_enqueue_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'slick-js', get_template_directory_uri() . '/js/slick.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'aos-js', get_template_directory_uri() . '/js/aos.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'select2-js', get_template_directory_uri() . '/js/select2.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'typed-js', get_template_directory_uri() . '/js/typed.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'gsap-js', get_template_directory_uri() . '/js/gsap.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'tween-js', get_template_directory_uri() . '/js/tween.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'scroll-js', get_template_directory_uri() . '/js/scroll.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'magic-js', get_template_directory_uri() . '/js/magic.js', array('jquery'), _S_VERSION, true );
wp_enqueue_script( 'scrollanim-js', get_template_directory_uri() . '/js/scrollanim.js', array('jquery'), _S_VERSION, true );

$theme_js_path = get_template_directory().'/js/main.js';
$theme_js_ver  = filemtime( $theme_js_path );

wp_enqueue_script( 'main-js', get_template_directory_uri() . '/js/main.js', array('jquery'), $theme_js_ver, true );


wp_register_script( 'customjs', get_template_directory_uri() . '/js/custom.js', array('jquery'), _S_VERSION, true );

$pathway_data = array(
				'siteurl'     => site_url(),
				'adminurl'    => admin_url(),
				'ajaxurl'     => admin_url( 'admin-ajax.php' ),
				'templateurl' => get_template_directory_uri()
);
wp_localize_script( 'customjs', 'pathway_obj', $pathway_data );
wp_enqueue_script( 'customjs');


/*Calendar*/
global $post;
if($post->post_name == 'events' ){
	wp_enqueue_script( 'underscore',  'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js', array('jquery'), _S_VERSION, true );
	wp_enqueue_script( 'moment',  'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js', array('jquery'), _S_VERSION, true );
	wp_enqueue_script( 'clndr', get_template_directory_uri() . '/js/clndr.js', array(), _S_VERSION, true );
	wp_register_script( 'eventjs', get_template_directory_uri() . '/js/event.js', array(), _S_VERSION, true );
	wp_localize_script( 'eventjs', 'pathway_obj', $pathway_data );
	wp_enqueue_script(  'eventjs');
}
/*Calendar*/

}
add_action( 'wp_enqueue_scripts', 'hollycross_scripts' );

Leave a Reply

Your email address will not be published. Required fields are marked *