fatBuzz of Fatbuzz Development Team
12/21/2017 - 11:52 AM

WordPress - Custom Loop

Add loop.php anywhere in the templates to add a loop for latest blog posts, customise the loop by adding arguements to WP_Query.

Supported arguements are found in the WordPress codex site.

<?php $the_query = new WP_Query( ); ?>
  // Start our WP Query
  <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
  // Display the Post Title with Hyperlink
  <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  // Display the Post Excerpt
  <?php the_excerpt(__('(more…)')); ?>
  // Repeat the process and reset once it hits the limit
  <?php endwhile; wp_reset_postdata();