Custom WordPress Loop
-
Hello. I am looking to create a custom loop for my homepage and then subsequent page on my site.
My idea is this:
Homepage
– Custom Static HTML
– Recent Post Grouped by Month
— January 2010 (Post 1, Post 2)
— February 2010 (Post 1, Post 2)
— Limit to last 5 postsPages
– Regular WordPress LoopWhat is the best way to accomplish this using index.php, home.php, page.php and single.php?
index.php
<?php get_header(); wp_reset_query(); if (is_home()) { include (TEMPLATEPATH . '/home.php'); } else { ?> <div id="page"> <div class="two-thirds"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endforeach; else: ?> <p><?php _e('Sorry, no content matched your criteria.'); ?></p> <?php endif; } ?> </div> <div class="one-third"> <?php get_sidebar(); ?> </div> </div> <?php get_footer(); ?>
home.php
<div class="one-third"> <h2>Recent News</h2> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h3><?php the_time('F Y'); ?></h3> <p id="post-<?php the_ID(); ?> class="news-item"><span class="news-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></span> <?php the_content('Read More...'); ?></p> <?php endwhile; ?> <?php else : ?> <h3><?php date("F Y"); ?></h3> <p>No recent updates...</p> </div> <?php endif; ?> </div> <?php get_footer(); ?>
Does this make sense?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom WordPress Loop’ is closed to new replies.