admin管理员组文章数量:1319027
I have a template section that displays testimonials. The testimonials have been set up as a post type and will be given categories to match product names. Here is the testimonial section:
<div class="testimonials-section">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-lg-8 col-md-12 col-sm-12 this-column">
<div class="autoplay testimonials-container">
<?php
$args = array( 'post_type' => 'testimonials', 'posts_per_page' => 999 );
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="entry-content">';
the_content();
echo '<h3>';
the_field('job_title');
echo ' / ';
the_title();
echo '</h3></div>';
endwhile;
else :
echo wpautop( 'Currently no Testimonials.' );
endif;
wp_reset_query();
?>
</div>
</div>
</div>
</div>
</div>
What I want to do is display testimonials on my single-products.php page if the product name matches the testimonial category.
Here is where I got to but I throw a critical error. Please excuse my ignorance, I am a beginner.
<?php
$ptitle = $product->get_name();
if (is_testimonial_category()) == $ptitle ) :
echo 'YES, this is where I would add in the above code....';
endif;
?>
I have a template section that displays testimonials. The testimonials have been set up as a post type and will be given categories to match product names. Here is the testimonial section:
<div class="testimonials-section">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-lg-8 col-md-12 col-sm-12 this-column">
<div class="autoplay testimonials-container">
<?php
$args = array( 'post_type' => 'testimonials', 'posts_per_page' => 999 );
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="entry-content">';
the_content();
echo '<h3>';
the_field('job_title');
echo ' / ';
the_title();
echo '</h3></div>';
endwhile;
else :
echo wpautop( 'Currently no Testimonials.' );
endif;
wp_reset_query();
?>
</div>
</div>
</div>
</div>
</div>
What I want to do is display testimonials on my single-products.php page if the product name matches the testimonial category.
Here is where I got to but I throw a critical error. Please excuse my ignorance, I am a beginner.
<?php
$ptitle = $product->get_name();
if (is_testimonial_category()) == $ptitle ) :
echo 'YES, this is where I would add in the above code....';
endif;
?>
Share
Improve this question
asked Oct 19, 2020 at 5:39
Marney FontanaMarney Fontana
31 bronze badge
1
- If Cameron's answer doesn't fix this, can you show us the code for your is_testimonial_category() function please? – Rup Commented Oct 19, 2020 at 8:18
1 Answer
Reset to default 1You've got an extra closing bracket
if (is_testimonial_category()) == $ptitle ) :
should be
if ( is_testimonial_category() == $ptitle ) :
本文标签: categoriesShow testimonials based on post category matching product name
版权声明:本文标题:categories - Show testimonials based on post category matching product name 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742051191a2418070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论