How to output script only on frontpage?
-
I have next code:
if ( !is_admin()) { function register_my_js() { wp_enqueue_script('my-js', get_bloginfo( 'template_directory' ).'/js/bg.js',array('jquery'), '1.0', true); } add_action('init', 'register_my_js'); }
I used is_home and is_front_page conditions, but when i do this, my script doesn’t include, without conditions script works but on all pages. And i need only on fron page, what should i do?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to output script only on frontpage?’ is closed to new replies.