Title: Query Confusion
Last modified: August 20, 2016

---

# Query Confusion

 *  Resolved [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/)
 * All,
 * I’m working on a custom theme and need to return details from a specific page
   as a summary on the home page. I’m fairly new to WP, so I’m not sure what I’m
   doing wrong. I tried following the description on the Codex [Function Reference/get post](http://codex.wordpress.org/Function_Reference/get_post)
   entry, but I haven’t been successful.
 * I need to return the page’s Title, permalink, and the page excerpt (which I’ve
   already [enabled](http://lewayotte.com/2010/07/01/easily-add-excerpt-support-for-pages-in-wordpress/)).
 * Any help will be greatly appreciated.
 * Thanks

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/#post-2258600)
 * try to use `get_page()` [http://codex.wordpress.org/Function_Reference/get_page](http://codex.wordpress.org/Function_Reference/get_page)
 * the example in the codex link might get you started; for details, please ask 
   again, if you have some code to work from.
 *  Thread Starter [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/#post-2258611)
 * This is what I have:
 *     ```
       <?php get_page( $page_id='5' );
                               while (have_posts()) : the_post();?>
                               <h3><?php the_title(); ?><br /><span>all about the spa and the team</span></h3>
                          <p><?php the_excerpt(); ?></p>
                               <p><a href="<?php the_permalink(); ?>">Continue reading</a></p>
                              <?php endwhile; ?>
       ```
   
 * It only returns the current page though, which is the home page, and not post
   id #5
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/#post-2258615)
 * following the example in here [http://codex.wordpress.org/Function_Reference/get_page](http://codex.wordpress.org/Function_Reference/get_page),
   your code might look like:
 *     ```
       <?php $this_page = get_page( $page_id='5' ); ?>
                               <h3><?php echo $this_page->post_title; ?><br /><span>all about the spa and the team</span></h3>
                          <p><?php echo apply_filters('the_excerpt', $this_page->post_excerpt); ?></p>
                               <p><a href="<?php echo get_permalink($this_page->ID); ?>">Continue reading</a></p>
       ```
   
 * (assuming that the page has a handwritten excerpt)
 * alternatively, if you want to use a `while(have_posts())` loop structure, you
   better use a query to get your page;
 * example:
 *     ```
       <?php query_posts('post_type=page&page_id=5');
                               while (have_posts()) : the_post();?>
                               <h3><?php the_title(); ?><br /><span>all about the spa and the team</span></h3>
                          <p><?php the_excerpt(); ?></p>
                               <p><a href="<?php the_permalink(); ?>">Continue reading</a></p>
                              <?php endwhile; wp_reset_query(); ?>
       ```
   
 * (untested)
 *  Thread Starter [3Plumes](https://wordpress.org/support/users/3plumes/)
 * (@3plumes)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/#post-2258620)
 * Nice!!! I used your second example and it works like a charm!! Thanks very much.

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

The topic ‘Query Confusion’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [3Plumes](https://wordpress.org/support/users/3plumes/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/query-confusion/#post-2258620)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
