WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Posts within Page (2 posts)

  1. greencode
    Member
    Posted 2 years ago #

    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(); ?>
  2. vtxyzzy
    Member
    Posted 2 years ago #

    You need a 'Loop' for each Custom Field. See this Codex article:

    http://codex.wordpress.org/The_Loop#Multiple_Loops

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.