jquery - 在 Woocommerce 的不同页面上加载 flexslider
问题描述
我已经使用这个简码在我的主页上加载了一个产品
<?php echo do_shortcode('[product_page id="195"]');?>
它会在产品下方和右侧产品标题、价格、数量和添加到购物车按钮上加载带有主图像和小缩略图的产品。这是我需要的。但是图像没有滑动功能或缩放功能。据我所知,如果您查看特定的产品页面,它会在产品图像上加载 flex 滑块和 jquery 缩放插件,以便它们可以像轮播一样滑动并单击它们来缩放图像。
知道如何使此功能也可以在我的主页上运行吗?
解决方案
我设法使用以下代码解决了这个问题。
// Enqueue/Add CSS and JS files
function amd_enqueue(){
// here home-page.php is the name of the template where it needs to load
if(is_page_template("home-page.php")){
wp_enqueue_script('zoom');
wp_enqueue_script('flexslider');
wp_enqueue_script('photoswipe-ui-default');
wp_enqueue_style('photoswipe-default-skin');
add_action( 'wp_footer', 'woocommerce_photoswipe' );
}
}
add_action( 'wp_enqueue_scripts', 'amd_enqueue' );
推荐阅读
- reactjs - 如何在 reactjs 中一次渲染一个可重用组件?
- php - Codeigniter - 克隆数据(但删除不存在的 1 列)
- testing - 如何在赛普拉斯点击 x 次
- ruby-on-rails - Rails 分组并用逗号加入
- java - 如何删除FTP目录中的所有txt文件?
- r - XGBoost 对变量选择有效吗?
- node.js - 将日志从 heroku node.js 脚本发送到我的 iPhone 的最简单方法
- python - 带有 MultiIndex 列的 Pandas DataFrame 中的布尔索引
- sharepoint - 如何使用 Apache Camel 读取 OneDrive 目录?
- ruby - 如何打印 Ruby 指令的内存地址?