WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add excerpt to my WP_query (3 posts)

  1. Mark Shirley
    Member
    Posted 1 year ago #

    I have a wp_query code below it calls a post type and some taxonomies as well as displaying some custom field how can I add the post excerpt to it - Thanks

    <?php $loop = new WP_Query( array( 'post_type' => 'movies','actors' => 'peter-smith', 'actress' => 'jane-smith', 'posts_per_page' => 10 ) ); ?>
    
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
    
    <h5>image</h5><a href="<?php the_permalink(); ?>"><img src="<?php the_field('image'); ?>" alt="text-here" /></a>
    <?php endwhile; ?>
  2. Mark Shirley
    Member
    Posted 1 year ago #

    I've done it see below

    <?php $loop = new WP_Query( array( 'post_type' => 'movies','actors' => 'peter-smith', 'actress' => 'jane-smith', 'posts_per_page' => 10 ) ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
    
    <h5>image</h5><a href="<?php the_permalink(); ?>"><img src="<?php the_field('image'); ?>" alt="text-here" /></a>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>
  3. WStringer2
    Member
    Posted 1 year ago #

    Thanks for posting the solution!

Topic Closed

This topic has been closed to new replies.

About this Topic