Title: Adding Excerpt to listing
Last modified: October 30, 2018

---

# Adding Excerpt to listing

 *  [chisomosteve](https://wordpress.org/support/users/chisomosteve/)
 * (@chisomosteve)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/)
 * I’d like to add the excerpt and a featured image to the listing output.
 * I’ve had a play with the templates/a-z-listing.php file but haven’t found a way
   to do it.
 * Can anyone help?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-excerpt-to-listing%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [dougfinn](https://wordpress.org/support/users/dougfinn/)
 * (@dougfinn)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10917145)
 * I see you haven’t done it yet, so this might be useful. I’m not sure if it’s 
   the best way to do it, but it works for me.
 * I copied the a-z-listing.example.php file from the templates folder to my child
   theme’s folder, changed the name to a-z-listing.php, then added the following
   lines to the while have_items() loop.
 *     ```
       while ( $a_z_query->have_items() ) :
          $a_z_query->the_item(); ?>
          <li>
          <a href="<?php $a_z_query->the_permalink(); ?>"><?php $a_z_query->the_title(); ?></a>
          // ============ START of new lines added  =============
          <?php 
             $a_z_query->query->the_post();
             echo "<br>" . wp_trim_words( get_the_content(), 15, ' ...' ); // 15 words, change to what you like
             wp_reset_postdata(); // Not sure if this is necessary here     
          ?>
          // ============ END of new lines added ================
          </li>
       <?php endwhile; ?>
       ```
   
 * You can style it by wrapping it in a div and adding a css class.
    -  This reply was modified 7 years, 5 months ago by [dougfinn](https://wordpress.org/support/users/dougfinn/).
    -  This reply was modified 7 years, 5 months ago by [dougfinn](https://wordpress.org/support/users/dougfinn/).
 *  Thread Starter [chisomosteve](https://wordpress.org/support/users/chisomosteve/)
 * (@chisomosteve)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10917362)
 * Thanks a lot, that display some text with each entry.
 * I’ve tried adding the following code to display the featured image but it doesn’t
   work:
    <?php $a_z_query->query->the_post_thumbnail(‘thumbnail’); ?>
 * Any idea what would make this work?
 *  Thread Starter [chisomosteve](https://wordpress.org/support/users/chisomosteve/)
 * (@chisomosteve)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10918167)
 * UPDATE – I’ve had to revert the plugin to 1.9.2 because of this issue:
    [https://wordpress.org/support/topic/links-to-a-z-listing-page-not-correctly-output-by-widget/](https://wordpress.org/support/topic/links-to-a-z-listing-page-not-correctly-output-by-widget/)
 * Now the code to output the text on the listing isn’t working.
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10941372)
 * The correct way to get more post information than the title and permalink is 
   to use something similar to below in your `a-z-listing.php` template file (this
   is not a complete template):
 *     ```
       while ( $a_z_query->have_items() ) :
       	$a_z_query->the_item();
       	$a_z_query->get_the_item_object( 'I understand the issues!' );
       	?>
       	<li>
       		<h2><a href="<?php $a_z_query->the_permalink(); ?>">
       			<?php $a_z_query->the_title(); ?>
       		</a></h2>
       		<p><?php the_excerpt(); ?></p>
       	</li>
       <?php endwhile; ?>
       ```
   
 * Please be aware that on a large list of posts this _will_ cause slowness or hit
   your memory limit. You need to pass the text `I understand the issues!` to `$
   a_z_listing->get_the_item_object()` exactly as written above to confirm that 
   you understand and accept this could be slow or break due to hitting a memory
   limit.
 *  Thread Starter [chisomosteve](https://wordpress.org/support/users/chisomosteve/)
 * (@chisomosteve)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10941944)
 * Ok thanks Daniel.
    Does that only work with version 2?
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10941949)
 * yes, it only works since 2.0

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding Excerpt to listing’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/a-z-listing_d8edfd.svg)
 * [A-Z Listing](https://wordpress.org/plugins/a-z-listing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/a-z-listing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/a-z-listing/)
 * [Active Topics](https://wordpress.org/support/plugin/a-z-listing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/a-z-listing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/a-z-listing/reviews/)

## Tags

 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)

 * 6 replies
 * 3 participants
 * Last reply from: [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/adding-excerpt-to-listing/#post-10941949)
 * Status: not resolved