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?

1 Answer 1


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; ?>
  • 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. Jul 6, 2011 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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