Categories
WordPress Templates

Your First WordPress Loop

In your underscores starter theme, create a new file called front-page.php.

Into it, copy the following code. You can remove anything that was put there by default by your editing program (if anything).

<?php
    get_header();
    if ( have_posts() ) : while ( have_posts() ) : the_post();
        the_content();
    endwhile;
    else :
        echo 'Sorry, no posts matched your criteria.';
    endif;
    get_sidebar();
    get_footer(); 
?>

Now go to the front page of your site.

What we are going to do is build on this loop in class in order for you to get comfortable with how WordPress pulls content from the database and displays it in the browser.