WordPress Templates

Your First WordPress Loop

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

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

<?php
    get_header();
    if ( have_posts() ) : while ( have_posts() ) : the_post();
        the_content();
    endwhile;
    else :
        _e( 'Sorry, no posts matched your criteria.', 'textdomain' );
    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.

 

Standard