WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the Yoko theme and would like to show the most recent full post in category 1 on the home page. I am a Wordpress newbie, but my approach was going to be to provide my own index.php in a child theme. The parent theme has relevant code that looks like this:

<?php /* Start the Loop */ ?>
  <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
  <?php endwhile; ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>

I had thought I needed to place a line like this prior to the while loop:

<?php query_posts('cat=1&posts_per_page=1'); ?>

However, I see the partial post only. I have also tried to do the same sort of thing with single.php. I am sure I am missing something simple. Can someone school me on the loop?

share|improve this question
up vote 1 down vote accepted

You can alter query_posts - see http://codex.wordpress.org/The_Loop - but maybe the best thing to do is use a page template with a new query. WP will default to home.php instead of index.php if one exists, so you can leave index.php alone for other page to use. See http://codex.wordpress.org/Class_Reference/WP_Query

Sample query; remove the permalink and/or title, if needed:

<?php $my_query = new WP_Query('cat=1&showposts=1'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">

<?php the_title(); ?></a>

<?php the_content(); ?>

<?php endwhile; ?>
share|improve this answer
That was very close. I could swear I tried a secondary query, but guess it wasn't quite right for some reason. I replaced the inner loop statements with those more appropriate in my theme and it gives me what I need. Thanks for your help. – Bill Eisenhauer Jul 6 '11 at 12:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.