WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Add excerpt to my WP_query

[Resolved] Add excerpt to my WP_query

  • 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; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • 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; ?>

    Thanks for posting the solution!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Add excerpt to my WP_query’ is closed to new replies.