我一辈子都搞不明白为什么这些领域没有成功(我已经尝试了30多种方法来实现这一目标)。
这与我以前使用这个出色(但令人沮丧)插件的时候完全一样。
这是我的代码:
<?php
$has_homepage_side_points = get_field(\'has_homepage_side_points\');
$homepage_side_points = get_field(\'homepage_side_points\');
?>
<?php if( $has_homepage_side_points === TRUE ) : ?>
<div class="wooside-column">
<?php
while( have_rows(\'homepage_side_points\') ) : the_row();
$has_how_to_use = get_sub_field(\'has_how_to_use\');
$how_to_use = get_sub_field(\'how_to_use\');
$has_featured_material = get_sub_field(\'has_featured_material\');
$featured_material = get_sub_field(\'featured_material\');
$has_featured_designer = get_sub_field(\'has_featured_designer\');
$featured_designer = get_sub_field(\'featured_designer\');
?>
<?php if( $has_how_to_use === TRUE ) : ?>
<?php
while( have_rows($how_to_use) ) : the_row();
$title = get_sub_field(\'title\');
$points = get_sub_field(\'points\');
?>
<div class="wooside-block how-to-use">
<?php if ($title != \'\') : ?>
<h3><?php echo $title; ?></h3>
<?php endif; ?>
<?php
while( have_rows(\'points\') ) : the_row();
$icon = get_sub_field(\'icon\');
$text = get_sub_field(\'text\');
?>
<div class="wb-point">
<img src="<?php echo $icon; ?>" class="wb-icon">
<p class="wb-point-text"><?php echo $points; ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php if( $has_featured_material === TRUE ): ?>
<?php while( have_rows($featured_material) ) : the_row();
$title = get_sub_field(\'title\');
$button_text = get_sub_field(\'button_text\');
?>
<div class="wooside-block featured-product">
<?php
$args = array (
\'post_type\' => \'product\',
\'post_status\' => \'publish\',
\'posts_per_page\' => \'1\',
\'product_tag\' => \'featured\'
);
$the_query = new WP_Query( $args ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php $product_thumbnail = get_the_post_thumbnail($the_query->post->ID, \'full\'); ?>
<div class="wooblock-inner"<?php if ($product_thumbnail != \'\') : ?> style="background-image: url(<?php echo $product_thumbnail; ?>);"<?php endif; ?>>
<a href="<?php the_permalink(); ?>" class="box-link"></a>
<?php if ($title != \'\') : ?>
<h3 class="featured-product-title">
<?php echo $title; ?>
</h3>
<?php endif; ?>
<div class="featured-product-name"><?php get_the_title(); ?></div>
<?php if ($button_text != \'\') : ?>
<div class="wooside-button">
<?php echo $button_text; ?>
</div>
<?php endif; ?>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
</div>
<?php endwhile;?>
<?php endif; ?>
<?php if( $has_featured_designer === TRUE ): ?>
<?php
while( have_rows($featured_designer) ) : the_row();
$title = get_sub_field(\'title\');
$button_text = get_sub_field(\'button_text\');
?>
<div class="wooside-block wooside-featured-designer">
<?php
$args = array (
\'category_name\' => \'case-study\',
\'tag\' => \'featured\',
\'posts_per_page\' => \'1\'
);
$the_query = new WP_Query( $args ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php $designer_thumbnail = get_the_post_thumbnail($the_query->post->ID, \'full\'); ?>
<div class="wooblock-inner"<?php if ($designer_thumbnail != \'\') : ?> style="background-image: url(<?php echo $designer_thumbnail; ?>);"<?php endif; ?>>
<a href="<?php the_permalink(); ?>" class="box-link"></a>
<?php if ($title != \'\') : ?>
<h3 class="featured-designer-title">
<?php echo $title; ?>
</h3>
<?php endif; ?>
<!--
<?php
$case_study = get_field(\'case_study_page_content\');
$is_case_study = get_field(\'is_case_study\'); ?>
<?php if( $is_case_study ): ?>
<div class="is-case-study">
<img src="/wp-content/themes/bolt/assets/img/case-study.svg" alt="Case Study">
</div>
<?php endif; ?>
-->
<div class="featured-designer-name"><?php get_the_title(); ?></div>
<?php if ($button_text != \'\') : ?>
<div class="wooside-button">
<?php echo $button_text; ?>
</div>
<?php endif; ?>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
</div>
<?php endwhile;?>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
以下是我所有字段的屏幕:
如果有人能帮我找出哪里出了问题,我将不胜感激。
EDIT (解决方案):
因此,您不能使用$post->ID或类似的标准调用,必须使用get\\u选项(“woocommerce\\u shop\\u page\\u ID”)。然后,您必须在对字段的调用中使用此选项,例如$has\\u homepage\\u side\\u points=get\\u字段(\'has\\u homepage\\u side\\u points\',get\\u选项(\'woocommerce\\u shop\\u page\\u id\');
谢谢,杰森。