0
나는 워드 프레스에서 작동하게하고 싶습니다 스크립트 파일 (service-graph.js)을 가지고 있습니다, 나는 스크립트가 wordpress에서 작동하는지 확실하지 않기 때문에 자바 스크립트의 꽤 기본적인 knowlogdge를 가지고 있습니다, 그 내용은 다음 :Wordpress에서이 스크립트를 호출하는 방법?
jQuery(document).ready(function() {
var url = window.location.pathname;
var path = url.split('/');
jQuery('.curve-item.' + path[2]).addClass('default');
if (path[2] == 'blueprint')
jQuery('.overview-graph .middle-item').addClass('default');
jQuery('.curve-item .logo').hover(
function() {
if (jQuery(this).parent().hasClass('default')) return;
jQuery(this).parent().addClass('on');
}, function() {
jQuery(this).parent().removeClass('on');
}
).css('cursor', 'pointer').on('click', function() {
location.href = '/services/' + jQuery(this).parent('.curve-item').data('target');
});
jQuery('.overview-graph .middle-item').on('click', function() {
location.href = '/services/blueprint';
}).css('cursor', 'pointer');
});
내가 functions.php
function wpb_adding_scripts() {
wp_register_script('service-graph', get_template_directory_uri() . '/js/service-graph.js', array('jquery'), '1.1', true);
wp_enqueue_script('service-graph');
}
add_action('wp_enqueue_scripts', 'wpb_adding_scripts');
아직 테스트하지 않았습니까? 너의 질문에서 그런 식으로 이해했기 때문에. 그리고이 페이지가/services 등이라면 js 파일이기 때문에 작동해야합니다. wordpress에서는 다르게 작동하지 않습니다. – mithataydogmus
예, 테스트했지만 현재 작동하지 않습니다. – Nation