douxie3625 2019-02-11 10:52
浏览 116

使用WooCommerce Product Subtitle插件在单个产品页面中未显示字幕

I'm using WooCommerce with Flatsome Theme.
I want to add a subtitle to my products.
I installed the WooCommerce Product Subtitle plugin and I see the subtitles only at the shop page, but NOT in the single product page.

I was looking much around the internet but not success.
In the plugin area, I see this help offer:

F.A.Q.s
1.Subtitle not visible in single product page?

This issue might be with the theme which you are using
Please do make sure that your theme has woocommerce_single_product_summary filter in the below files

woocommerce_single_product_summary filter file list :

  1. your-theme/woocommerce/content-product.php

What do I have to do? Here is the page:

<?php
/**
 * The template for displaying product content within loops
 */

defined( 'ABSPATH' ) || exit;

global $product;

// Ensure visibility.
if ( empty( $product ) || ! $product->is_visible() ) {
    return;
}

// Check stock status.
$out_of_stock = get_post_meta( $post->ID, '_stock_status', true ) == 'outofstock';

// Extra post classes.
$classes   = array();
$classes[] = 'product-small';
$classes[] = 'col';
$classes[] = 'has-hover';

if ( $out_of_stock ) $classes[] = 'out-of-stock';

?>

<div <?php fl_woocommerce_version_check( '3.4.0' ) ? wc_product_class( $classes ) : post_class( $classes ); ?>>
    <div class="col-inner">
    <?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
    <div class="product-small box <?php echo flatsome_product_box_class(); ?>">
        <div class="box-image">
            <div class="<?php echo flatsome_product_box_image_class(); ?>">
                <a href="<?php echo get_the_permalink(); ?>">
                    <?php

                        /**
                         *
                         * @hooked woocommerce_get_alt_product_thumbnail - 11
                         * @hooked woocommerce_template_loop_product_thumbnail - 10
                         */
                        do_action( 'flatsome_woocommerce_shop_loop_images' );
                    ?>
                </a>
            </div>
            <div class="image-tools is-small top right show-on-hover">
                <?php do_action( 'flatsome_product_box_tools_top' ); ?>
            </div>
            <div class="image-tools is-small hide-for-small bottom left show-on-hover">
                <?php do_action( 'flatsome_product_box_tools_bottom' ); ?>
            </div>
            <div class="image-tools <?php echo flatsome_product_box_actions_class(); ?>">
                <?php do_action( 'flatsome_product_box_actions' ); ?>
            </div>
            <?php if ( $out_of_stock ) { ?><div class="out-of-stock-label"><?php _e( 'Out of stock', 'woocommerce' ); ?></div><?php } ?>
        </div><!-- box-image -->

        <div class="box-text <?php echo flatsome_product_box_text_class(); ?>">
            <?php
                do_action( 'woocommerce_before_shop_loop_item_title' );

                echo '<div class="title-wrapper">';
                do_action( 'woocommerce_shop_loop_item_title' );
                echo '</div>';


                echo '<div class="price-wrapper">';
                do_action( 'woocommerce_after_shop_loop_item_title' );
                echo '</div>';

                do_action( 'flatsome_product_box_after' );

            ?>
        </div><!-- box-text -->
    </div><!-- box -->
    <?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
    </div><!-- .col-inner -->
</div><!-- col -->
  • 写回答

2条回答 默认 最新

  • doupacan2098 2019-02-11 11:29
    关注

    maybe the subtitle is not hooked anywhere in the single product page.

    Can you try to add this snippet to your theme's functions.php file?

    add_action('woocommerce_shop_loop_item_title', 'fc_single_product_subtitle');
    function fc_single_product_subtitle() {
    
        $subtitle = get_product_subtitle( get_the_ID() );
    
        if( ! empty( $subtitle ) ) echo $subtitle;
    }
    

    Let me know and good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大