Loop Templates

Contents

Introduction

Loop template files are used to format the loop based on what type of page you are visiting.

What Template File is Used?

You can have loop templates for different loops. For example: loop-archive.php or loop-category.php which represent different loops for archives and categories, respectively.

Examples

You can call a loop from inside one of you page templates like this:

<?php
/* Run the loop to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-index.php and that will be used instead.
*/
get_template_part( 'loop', 'category' );
?>

Using this method will call the file loop-category.php and run the content within in it.
Inside loop-category.php you might have code to format the loop just for category pages.