Wordpress Custom Loop


/ Published in: PHP
Save to your folder(s)

Custom Loop for Wordpress Main page, show static content and 1 selected page.


Copy this code and paste it in your HTML
  1. <?php if (is_home()) {
  2. // we're on the home page, so lets show the welcome message, and a single page beneath..
  3. ?>
  4.  
  5. <div id="content-1">
  6. <div id="content-1-left">
  7. <img src="#" alt="" />
  8. </div><!--End Content-1-Left -->
  9. <div id="content-1-right">
  10. <h1>Welcome!</h1>
  11. <p>Ut vitae velit sed elit tincidunt fermentum. Phasellus a nunc sit amet quam dapibus varius eget eget ligula. Quisque sit amet ligula a enim convallis aliquet non quis enim. Vestibulum aliquam mollis lobortis. Praesent pharetra pellentesque mauris. Phasellus id magna vitae est accumsan aliquam non ut eros. Nullam dignissim massa vel arcu molestie tempor id vitae elit. Sed aliquet dolor ac leo tincidunt aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus ut felis pretium tellus vestibulum lobortis ac eu nibh. Pellentesque orci neque, sodales in aliquam eu, tincidunt et diam. Aliquam eget sapien tortor, malesuada tempor felis. Morbi laoreet justo sit amet turpis congue nec posuere enim varius. Nunc fringilla blandit neque sit amet sagittis.</p>
  12. <br/>
  13. </div><!--End Content 1 Right -->
  14. </div><!--End Content 1 -->
  15. <br class="clear"/>
  16. <div id="content-splitter">
  17. <p>&nbsp;</p>
  18. </div>
  19. <div id="content-2">
  20. <div id="content-2-left">
  21. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  22.  
  23. <?php $featured_page = new WP_Query("page_id=2"); //Show the Featured Content By ID. ?>
  24.  
  25. <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
  26.  
  27. <?php the_content(); ?>
  28.  
  29. <?php endwhile; else: ?>
  30.  
  31. <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
  32.  
  33. <?php endif; ?>
  34.  
  35. <br/>
  36. </div><!--End Content-2-Left -->
  37. <div id="content-2-right">
  38. <img src="#" alt="" />
  39. </div><!--End Content-2-Right -->
  40. </div><!--End Content 2-->
  41. <br class="clear"/>
  42.  
  43. <?php }?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.