Insert Latest Blog Posts on Static Home Page?
-
For starters, I’m a complete newb with WP. No surprise. I’m rather frustrated because I do not know how to implement a loop to post the most recent blog posts on the page. I’m not looking for a list of just the titles. I would like to have the heading, date, article teaser, read more link, etc.
I’m using a Naked WordPress Theme template and it comes with a ‘page-home.php’ template. I don’t know if I’m missing something on how to integrate a loop?
I don’t have the site live, but could use some pointers on how I can integrate a loop for blog posts, or if someone can guide me in the right direction?
My ‘page-home.php’ code:
<?php /** * Template Name: Sidebar/Home Page * * This page template has a sidebar built into it, * and can be used as a home page, in which case the title will not show up. * */ get_header(); // This fxn gets the header.php file and renders it ?> <div id="primary" class="row-fluid"> <div id="content" role="main" class="span8"> <?php if ( have_posts() ) : // Do we have any posts/pages in the databse that match our query? ?> <?php while ( have_posts() ) : the_post(); // If we have a page to show, start a loop that will display it ?> <article class="post"> <?php if (!is_front_page()) : // Only if this page is NOT being used as a home page, display the title ?> <h1 class='title'> <?php the_title(); // Display the page title ?> </h1> <?php endif; ?> <div class="the-content"> <?php the_content(); // This call the main content of the page, the stuff in the main text box while composing. // This will wrap everything in paragraph tags ?> <?php wp_link_pages(); // This will display pagination links, if applicable to the page ?> </div><!-- the-content --> </article> <?php endwhile; // OK, let's stop the page loop once we've displayed it ?> <?php else : // Well, if there are no posts to display and loop through, let's apologize to the reader (also your 404 error) ?> <article class="post error"> <h1 class="404">You have received this message in error</h1> </article> <?php endif; // OK, I think that takes care of both scenarios (having a page or not having a page to show) ?> </div><!-- #content .site-content --> <!-- <div id="sidebar" role="sidebar" class="span4"> <?php get_sidebar(); // This will display whatever we have written in the sidebar.php file, according to admin widget settings ?> </div>#sidebar --> </div><!-- #primary .content-area --> </div> <?php get_footer(); // This fxn gets the footer.php file and renders it ?>
Thank you.
- The topic ‘Insert Latest Blog Posts on Static Home Page?’ is closed to new replies.