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 ) :