我对这个答案进行了高低搜索,但似乎找不到。
我在主页上有锚点,顶部菜单中的链接可以滚动到它们。
这在主页上效果很好,但在子页面上不起作用。
下面是我的代码:
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
event.stopPropagation();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 2000, …Run Code Online (Sandbox Code Playgroud) 我想要让每个图像的“标题”显示在 Woocommerce 产品库中每个图像的下方。不是主图像,而是较小的可点击缩略图。
我的所有图像目前都已设置标题。
我查看了product-thumbnails.php并找到了以下代码:
if ( $attachment_ids && has_post_thumbnail() ) {
foreach ( $attachment_ids as $attachment_id ) {
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id );
}
}
Run Code Online (Sandbox Code Playgroud)
我相信这是我需要编辑的内容,但我不确定要添加什么。
我还发现这篇文章提出了类似的问题,但对于标题Show title under Product gallery in WooCommerce,但是当我添加它时它不起作用
有任何想法吗?
编辑
因此,我已将 wc-template-functions.php 中的函数复制到我的子主题functions.php 文件中:
function wc_get_gallery_image_html( $attachment_id, $main_image = false ) {
$flexslider = (bool) apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) );
$gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );
$thumbnail_size = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) );
$image_size = apply_filters( 'woocommerce_gallery_image_size', …Run Code Online (Sandbox Code Playgroud)