[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 499
  • Last Modified:

Wordpress Loop show single post on index page

I am using the following code on the index.php page of my template.  This is looping and showing multiple posts instead of just the last post.  How do I update this to only show the latest post on the index page?
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>	
							<div class="content1">
								<div class="topic">
									<div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="5" alt=""/></div>
									<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
									<div class="info">Author: <?php the_author_link() ?> <span><?php the_time('d.m.Y') ?></span></div>
									<div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="10" alt=""/></div>
								</div>
								<div class="text511">
									<div class="text_top511">
										<?php the_content('Read the rest of this entry &raquo;'); ?>
									</div>
									<div class="spacer"><br style="clear:both;"/></div>
								</div>
								<div class="comment"><a href="<?php comments_link(); ?>">read users' comments</a> (<?php comments_number('0', '1', '%', 'number'); ?>)</div>
								<div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="15" alt=""/></div>
							</div>
		
		
								<?php endwhile; ?>

Open in new window

0
pda4me
Asked:
pda4me
1 Solution
 
i-CONICACommented:
Would the attached work? Not tested, don't have a wordpress installation to hand...
<?php if ( have_posts() ) : the_post(); ?>     
                                                        <div class="content1">
                                                                <div class="topic">
                                                                        <div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="5" alt=""/></div>
                                                                        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                                                                        <div class="info">Author: <?php the_author_link() ?> <span><?php the_time('d.m.Y') ?></span></div>
                                                                        <div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="10" alt=""/></div>
                                                                </div>
                                                                <div class="text511">
                                                                        <div class="text_top511">
                                                                                <?php the_content('Read the rest of this entry &raquo;'); ?>
                                                                        </div>
                                                                        <div class="spacer"><br style="clear:both;"/></div>
                                                                </div>
                                                                <div class="comment"><a href="<?php comments_link(); ?>">read users' comments</a> (<?php comments_number('0', '1', '%', 'number'); ?>)</div>
                                                                <div class="spacer"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/spacer.gif" width="1" height="15" alt=""/></div>
                                                        </div>

Open in new window

0
 
pda4meAuthor Commented:
Perfect, thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now