【发布时间】:2018-12-20 00:08:38
【问题描述】:
如何将自定义 js 文件仅引用到 Woocommerce 编辑/添加产品页面?
提前致谢。
调
【问题讨论】:
标签: woocommerce
如何将自定义 js 文件仅引用到 Woocommerce 编辑/添加产品页面?
提前致谢。
调
【问题讨论】:
标签: woocommerce
这对我有用(将添加到主题的 functions.php 文件中):
//wholesale-prices
function add_admin_scripts( $hook ) {
global $post;
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
if ( 'product' === $post->post_type ) {
wp_enqueue_script( 'myscript', get_stylesheet_directory_uri().'/js/wholesale-prices.js' );
}
}
}
add_action( 'admin_enqueue_scripts', 'add_admin_scripts', 10, 1 );
【讨论】: