【发布时间】:2016-03-22 17:14:03
【问题描述】:
大家好,我希望你们能帮助我。 我用 ACF 为我的产品创建了 2 个字幕(subtitle 和 subtitle_2) 我希望它们出现在我的产品页面和我的主页/商店(在产品“小盒子”中)的产品标题下方(呃!!)。
到目前为止,通过编辑我的 single-product.php 文件,我设法让它们出现在产品页面上,但它们不在正确的位置,我不知道如何将它们移动到我想要的位置。我认为它们被视为页面标题的副标题,而不是产品标题的副标题。 (至于首页,它们根本没有出现,我们一次解决1个问题)
<?php
/**
* The Template for displaying all single products.
*
* Override this template by copying it to yourtheme/woocommerce/single-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<div id="page-title">
<div class="width-container">
<h3><?php woocommerce_page_title(); ?></h3>
<?php if(function_exists('bcn_display')) {
echo '<div id="bread-crumb">';
bcn_display();
echo '</div>';
}?>
<div class="clearfix"></div>
</div>
</div><!-- close #page-title -->
<?php endif; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_field('subtitle'); ?>
<?php the_field('subtitle_2'); ?>
<?php wc_get_template_part( 'content', 'single-product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
</div>
<?php
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
<div class="clearfix"></div>
</div>
这里是相应产品页面的链接:http://tinyurl.com/pzum42k
任何帮助将不胜感激! 提前致谢, G
【问题讨论】:
-
标有“出现字幕的地方”的红圈里面没有任何东西。你能澄清一下吗?
-
@Graham :确实如此。如果您不单击图像并放大它,您可能看不到它,因为文本是黑底灰的,但字幕在那里。
标签: php wordpress woocommerce advanced-custom-fields