这是其他任何可能遇到这一问题的人的答案。
<?php
/*
Template Name: Products By Brand
Template Post Type: Brand
*/
get_header();
// get all of the custom taxonomy terms
$taxonomy = \'product_type\';
$arg_terms = array(
\'orderby\' => \'id\',
\'order\' => \'ASC\',
);
$taxonomy_terms = get_terms($taxonomy, $arg_terms);
$counter=0;
$column_divide = 4;
?>
<div class="fl-content-full container">
<div class="row">
<div class="fl-content col-md-12">
<div class="fl-row fl-row-full-width fl-row-bg-none">
<div class="fl-row-content-wrap">
<div class="fl-row-content fl-row-fixed-width">
<div class="row">
<div class="col-lg-12">
<?php echo get_the_post_thumbnail( get_the_ID(), \'medium\' ); ?>
<p>product summary <?php the_field(\'product_summary\'); ?></p>
<p>manufacture website <?php the_field(\'website_url_en\'); ?></p>
</div>
</div>
<div class="row">
<?php
// if there are some taxonomy terms, loop through each one and get the posts in that term
if($taxonomy_terms) {
foreach($taxonomy_terms as $taxonomy_term) {
$args = array(
\'post_type\' => array(\'brand\',\'products\'),
"$taxonomy" => $taxonomy_term->slug,
\'post_status\' => \'publish\',
\'posts_per_page\' => -1,
);
$query = new WP_Query( $args ); ?>
<?php
if ( $query->have_posts() ) : ?>
<div class="col-lg-12">
<h2><?php echo $taxonomy_term->name; ?></h2>
</div>
<?php while ( $query->have_posts() ) : $query->the_post(); $counter++;
$brand_association = get_field(\'brand_association\');
if( $brand_association ):
?>
<div class="col-lg-3">
<p><img src="<?php the_field(\'product_image\') ?>"/></p>
<p><?php the_field(\'product_details\') ?></p>
<p><a href="<?php the_field(\'hyperlink_to_product_page\') ?>">Product Web Page</a></p>
<p><a href="<?php the_field(\'hyperlink_to_specifications\') ?>">Product Sepcifications</a></p>
</div>
<?php endif; endwhile;
if($counter % $column_divide == 0) echo \'<div class="row">\';
?>
<?php wp_reset_postdata(); // so nothin\' weird happens to other loops
endif;
}
}
?>
</div><!-- END .col-lg-12-->
</div><!-- END .row -->
</div>
</div><!-- END .fl-content .col-lg-12-->
</div><!-- END .row -->
</div><!-- END .fl-content-full .container -->
</div>
<h1>hero banner - using beaver themer</h1>
<?php get_footer(); ?>