JS file work only in index page
Question
i load my js files in functions file of the WP but it seems that the script only called in the index page and for other pages it doesnt work..
here is my code in functions file:
function loadjs() {
wp_register_script('customjs', get_template_directory_uri() . '/custom/js/script.js', '', 1, true);
wp_enqueue_script('customjs');
$translation_array = array( 'templateUrl' => get_stylesheet_directory_uri() );
wp_localize_script('customjs', 'object_name', $translation_array);
}
add_action('wp_enqueue_scripts', 'loadjs');
please help 🙂
0
functions, javascript, php
3 years
2020-04-01T16:51:16-05:00
2020-04-01T16:51:16-05:00 0 Answers
94 views
0
Leave an answer