दोस्तों इस पार्ट में हम wp_enqueue_scripts add_action hook की हेल्प से हम header and footer में css और js ऐड करेंगे |
<?php
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'mani_main_style', get_stylesheet_uri() );
wp_enqueue_script( 'mani_main_javascript', get_template_directory_uri() . '/js/mytheme.js', array('jquery'), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
?>
How to add css using wp_enqueue_style
wp_enqueue_style function में नीचे दिए example के अनुसार वैल्यू पास करेंगे |
wp_enqueue_style( '411_for_green', get_template_directory_uri() . '/css/411.css', array(), '1.0', '(max-width: 411px)');
लास्ट वैल्यू ये बताती है की आपको ये css कहा पर पर दिखाई देगी यदि आप चाहते है की ये वैल्यू किसी पर्टिकुलर divice पर ही दिखाई दे तो आप वो भी कर सकते है | यहाँ पर आप range query का भी प्रयोग कर सकते हो | उदाहरण नीचे दिया है |
wp_enqueue_style( '768_for_pink', get_template_directory_uri() . '/css/768.css', array(), '1.0', '(min-width: 411px) and (max-width: 768px)');