the_excerpt giving me the wrong excerpt
-
Hi Everyone,
I have a post type called product_type
on my single-prduct_type.php page I need to have a description of the product type and then list the products under it that fall into that product type (That’s what that meta query does)For some reason the_excerpt(); and echo get_the_excerpt(); give me the excerpt for the product type and not the product
Here’s my single-product_type.php
<?php /** * The template for displaying product category post type * * @package WordPress * @subpackage FoundationPress * @since FoundationPress 1.0 */ get_header(); ?> <div class="row"> <?php do_action( 'foundationpress_before_content' ); ?> <?php while ( have_posts() ) : the_post(); ?> <article <?php post_class() ?> id="post-<?php the_ID(); ?>"> <?php do_action( 'foundationpress_post_before_entry_content' ); ?> <div class="entry-content"> <div class="row"> <div class="column"> <div class="text-center"> </div><!--text-center--> <div class="skinnycol"> <header class= text-center> <h1 class="entry-title brand-color"><?php the_title(); ?></h1> <?php the_content(); ?> </header> </div><!--skinnycol--> </div><!--column--> </div><!--row--> </div> <!--entry content--> <footer> <?php wp_link_pages( array('before' => '<nav id="page-nav"><p>' . __( 'Pages:', 'foundationpress' ), 'after' => '</p></nav>' ) ); ?> <p><?php the_tags(); ?></p> </footer> </article> <?php endwhile;?> <?php wp_reset_postdata(); ?> <?php $product_types = get_posts(array( 'post_type' => 'products', 'posts_per_page' => 5000, 'meta_query' => array( array( 'key' => 'product_type_dude', // name of custom field 'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234" 'compare' => 'LIKE' ) ) )); ?> <?php if( $product_types ): ?> <ul class="product-list"> <?php foreach( $product_types as $product ): ?> <?php $excerpt = get_the_excerpt( $product->ID ); ?> <li class="clearfix archive-item"> <div class="small-12 medium-4 columns"> <a href="<?php echo get_permalink( $product->ID ); ?>"> <?php echo get_the_post_thumbnail($product->ID,'thumbnail'); ?> </a> </div> <div class="small-12 medium-8 columns"> <a href="<?php echo get_permalink( $product->ID ); ?>"> <h4 class="brand-color"><?php echo get_the_title( $product->ID ); ?></h4> </a> <?php echo get_the_excerpt( $product->ID ); ?> <!-- why doesn't this work? --> </br></br> <a href="<?php echo get_permalink( $product->ID ); ?>"> Read more about <?php echo get_the_title( $product->ID ); ?> </a> </div> </li> <hr> <?php endforeach; ?> </ul> <?php endif; ?> <?php do_action( 'foundationpress_after_content' ); ?> </div> <?php get_footer(); ?>
you can see I tried
<?php wp_reset_postdata(); ?>
to no avail.
Why would it call all the right titles, featured images, and permalinks but not the correct excerpt. I triedthe_content();
as well and it did the same thing.Here’s is a link to the page where you can see all the excerpts repeating: https://silence.kevinalves.me/product_type/baffles/
HALP
Thanks in advance!
- The topic ‘the_excerpt giving me the wrong excerpt’ is closed to new replies.