- 状态
- 已由作者解决
- 解决于
- WoodMart 8.0.2
- 相关插件/主题
- Woodmart
- 主题标签
- Compatibility
问题概述
如果您将 Woodmart 主题与 WPML 搭配使用,您可能会遇到翻译 Product Layout 时卡住且无法完成的问题。此外,您会发现类似的错误:
Call to a member function get_gallery_image_ids() on null .../wp-content/themes/woodmart/woocommerce/single-product/product-image.php:27
临时解决方法
请在继续操作前,确保对您的站点进行完整备份。
- 打开您主题的 functions.php 文件。
- 添加以下代码片段:
add_action( 'woocommerce_before_template_part', function () { global $product; if ( wp_is_json_request() && ! $product ) { $random_product = new WP_Query( array( 'posts_per_page' => '1', 'post_type' => 'product', ) ); while ( $random_product->have_posts() ) { $random_product->the_post(); $product_id = get_the_ID(); } wp_reset_postdata(); $product = wc_get_product( $product_id ); } } ); - 清除缓存并重新翻译您的产品布局。
- 前往 WordPress 仪表板 -> WoodMart -> Patcher。
- 选择 618307 号补丁。