WordPress Loop at Index.php
Category: Wordpress
Here is how to make a loop that will show articles at front page. The setting how many you want to show the articles located at Setting > Reading in your WordPress administration page.
Put this code in your index.php at your theme folder
<?php if(have_posts()):while(have_posts()):the_post();?> <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2> <?php the_content(); ?> <?php endwhile; ?> <?php endif; ?>
That is it! Although you didn’t prepared for header.php it still works when you access to your WordPress address online or offline (localhost).