Title: excerpt in mini-loop
Last modified: August 18, 2016

---

# excerpt in mini-loop

 *  [superted](https://wordpress.org/support/users/superted/)
 * (@superted)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/excerpt-in-mini-loop/)
 * I have a [blog](http://powermyhealth.com/) with a static front page that I want
   to show excerpts from recent posts. I have a second page (/success-stories) with
   the same basic feature.
 * If I use a mini loop that basically copies The Loop:
 *     ```
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>...
       ```
   
 * then it messes up a custom nav element I have in my sidebar because the counter
   seems to affect the is_page() function and my nav element can’t tell what page
   it is on.
 * If I use a mini loop with a custom call to the db:
 *     ```
       $news=$wpdb->get_results("SELECT ID,post_title,post_date,post_excerpt FROM $wpdb->posts
       WHERE post_type='post' AND post_status='publish' ORDER BY 'ID' DESC LIMIT $how_many");
       foreach($news as $np){...
       ```
   
 * then I can’t seem to pull post_excerpt and display it on the page.
 *     ```
       echo $np->post_excerpt; // i tried this line with the "printf" version of the mini-loop
       echo apply_filters('the_excerpt', $np->post_excerpt); // and then this line just to test it out!
       ```
   
 * For now I’ll just be displaying the title and date of the most recent posts. 
   If you have some insight into this, please let me know.
 * BTW, there are lots of questions about this in the support forum and none that
   I have found seem to work without being in the loop.
 * [http://powermyhealth.com/](http://powermyhealth.com/) to check out the site 
   I’m working on.
 * Thanks

Viewing 1 replies (of 1 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/excerpt-in-mini-loop/#post-655311)
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
 * See the section specifically on using WP_Query() to create a new query object(
   rather than using query_posts(), which I assume you meant above when you mentioned
   copying The Loop).
 * Similar issue discussed recently here:
 * [http://wordpress.org/support/topic/142973](http://wordpress.org/support/topic/142973)

Viewing 1 replies (of 1 total)

The topic ‘excerpt in mini-loop’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/excerpt-in-mini-loop/#post-655311)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
