Title: Posts within Page
Last modified: August 20, 2016

---

# Posts within Page

 *  Resolved [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/posts-within-page/)
 * I think I’m going a little mad! I have created a page template to be used for
   my homepage. On there there are a number of custom fields and I would also like
   to display the content of 3 posts.
 * What’s happening with the code I’m using below is the first custom field is showing(
   custom-1) and the 3 posts but then everything after that i.e. the next custom
   field (custom-2) is not.
 * I know this is a basic mistake on my part but I can’t think what I’ve done wrong…
   It’s been a long day (that’s what excuse I’m using anyway 😉
 *     ```
       <?php
       /**
        * Template Name: Test Page
       **/
   
       get_header(); ?>
   
       		<div id="primary">
       			<div id="content" role="main">
   
       	<div class="entry-content">
   
       <?php echo get_post_meta($post->ID, 'custom-1', true); ?>
   
       <?php query_posts('cat=1&showposts=3');?>
       <?php while (have_posts()) : the_post(); ?>
       <div>
       <?php
       global $more;
       $more = 0;
       the_content("More...");
       ?>
       </div>
       <?php endwhile;?>
   
       <?php echo get_post_meta($post->ID, 'custom-2', true); ?>	
   
       	</div><!-- .entry-content -->
   
       			</div><!-- #content -->
       			<?php get_sidebar(); ?>
       		</div><!-- #primary -->
   
       <?php get_footer(); ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/posts-within-page/#post-2241028)
 * You need a ‘Loop’ for each Custom Field. See this Codex article:
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)

Viewing 1 replies (of 1 total)

The topic ‘Posts within Page’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/posts-within-page/#post-2241028)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
