0

I have a static wordpress front page. I want the code that works on my regular blog template to work on the homepage too. Currently, it only shows one post. The code in the main index.php is this...

<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>

content.php calls this....

<div class="col-md-4">
<?php the_excerpt(); ?>
</div><!-- /col-md-4 -->

This works great while on the blog page. But i can't get this exact same content on to the static home page. I know I need a different query for homepage but no idea what that is. Any help appreciated!

  • What WordPress template are you putting this code into? Have you set a frontpage under Settings -> Reading ? – Howdy_McGee Apr 2 '15 at 20:53
1

The loop in a page loads only the content of the page. Thus you see only one post.

You have to set up a "Page of Posts". You can find basic examples in the codex at Page Templates. But using it as static front page results in some problems. The links to follow pages will not work. You have to evaluate get_query_var('page') instead of get_query_var('paged').

There are also some plugins, but I don't think that they solve the problems with a static front page:

  • Posts in Page
  • Powerful Posts Per Page
  • Add Posts to Pages

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.