【发布时间】:2015-07-12 14:52:49
【问题描述】:
我正在开发一个用于在页面中加载 javascript 的 wordpress 插件。 但我希望这个插件只在选定的页面上加载。不是所有页面。 有人可以建议怎么做吗? 这是代码。
add_action('wp_enqueue_scripts', 'soundninja_enqueue');
function soundninja_enqueue($hook)
{
wp_enqueue_script('soundninja', // id
'http://soundninja.github.io/SNtest/build/Soundninja.min.js', // path
array('jquery'), // dependencies
0, // appends ?ver=$wordpress_version
true // in_footer
);
}
【问题讨论】:
-
在特定页面上,意思是具有特定帖子ID的页面?
-
两者都有!一个特定的页面和一个特定的帖子 ID。