Title: Multiple get_template_part
Last modified: August 20, 2016

---

# Multiple get_template_part

 *  Resolved [Gaxas](https://wordpress.org/support/users/gaxas/)
 * (@gaxas)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/)
 * Hello,
 * I have a problem :/
 * I created three post templates (this is in the index.php):
 *     ```
       <?php get_template_part( 'loop', 'ets' ); ?>
       <?php get_template_part( 'loop', 'ls' ); ?>
       <?php get_template_part( 'loop', 'info' ); ?>
       ```
   
 * but problem is when I open my web page, all posts sorts by this get_template_part(
   ets, ls and info)
 * for example:
    ets post2 2013-03-02 ets post1 2013-03-01 ls post2 2013-03-04 ls
   post1 2013-03-03 inf post1 2013-03-05
 * Question: how I can sort this by post date instead of get_template_part sort.
 * Thanks and sorry for my english 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/#post-3591755)
 * you will probably need to replace the three templates with one, and adjust the
   parameters used for the queries within the new template.
 * please post the code of each template.
 * what theme are you using?
 *  Thread Starter [Gaxas](https://wordpress.org/support/users/gaxas/)
 * (@gaxas)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/#post-3591782)
 * Thank you for answer.
 * I using tweaker4 theme. I have three different post styles: ets, ls and info.
 * This is loop-ets.php code:
 *     ```
       <!-- Start the Loop. -->
       <?php $queryname = new WP_Query('cat=10,11,12,13,14,15,16,17,18'); while ($queryname->have_posts()) : $queryname->the_post();  ?>
   
        <div class="post-ets2">
   
       	<div class="entry-content">
   
       			<?php if ( has_post_thumbnail()) : ?>
       			   <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail', array('class' => 'thumbalign', 'title' => '', 'alt' => '' )); ?></a>
       			<?php endif; ?>
   
                   <!-- Display the Title as a link to the Post's permalink. -->
        <div class="ets-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
   
         <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
        <div class="ets-date"><?php the_time('F jS, Y') ?></div><div class="ets-cat">ETS 2 mods / <?php the_category(', '); ?></div>
   
       			<div class="ets-ls-text"><?php if(!empty($post->post_excerpt)): ?>
       				<?php the_excerpt(); ?>
       			<?php else: ?>
       				<?php the_content('<div class="ets-ls-moretext">Read more...</div>'); ?>
       <a href="<?php the_permalink(); ?>#more-<?php the_ID(); ?>"><div class="ets-comment"><?php comments_number( 'Comment (0)', 'Comment (1)', 'Comments (%)' ); ?></a></div>
   
       			<?php endif; ?>
       			</div>
       	</div><!-- close .entry-content-->
        </div> <!-- closes the first div box -->
        <?php endwhile; ?>
       ```
   
 * Thank You for help
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/#post-3591786)
 * what is the difference between those three post styles?
 * do the post styles have different categories?
    do the oputputs have differnent
   layouts?
 * do you need a fixed number of posts per post style in the output?
 *  Thread Starter [Gaxas](https://wordpress.org/support/users/gaxas/)
 * (@gaxas)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/#post-3591811)
 * Layout is one. Difference is div class, example: <div class=”post-ets2″>; <div
   class=”ets-title”> etc.
 * This is loop-ls.php code:
 *     ```
       <!-- Start the Loop. -->
       <?php $queryname = new WP_Query ('cat=189,200,230,245,268,271,278'); while ($queryname->have_posts()) : $queryname->the_post(); ?>
   
        <?php if ( in_category( array('189', '200', '230', '245', '268', '271', '278')) ) { ?>
                  <div class="post-ls">
        <?php } else { ?>
                  <div class="post">
        <?php } ?>
   
       <div class="entry-content">
   
       			<?php if ( has_post_thumbnail()) : ?>
       			   <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail', array('class' => 'thumbalign', 'title' => '', 'alt' => '' )); ?></a>
       			<?php endif; ?>
   
                   <!-- Display the Title as a link to the Post's permalink. -->
        <div class="ls-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
   
         <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
        <div class="ls-date"><?php the_time('F jS, Y') ?></div><div class="ls-cat">FS 2013 mods / <?php the_category(', '); ?></div>
   
       			<div class="ets-ls-text"><?php if(!empty($post->post_excerpt)): ?>
       				<?php the_excerpt(); ?>
       			<?php else: ?>
       				<?php the_content('<div class="ets-ls-moretext">Read more...</div>'); ?>
       <a href="<?php the_permalink(); ?>#more-<?php the_ID(); ?>"><div class="ls-comment"><?php comments_number( 'Comment (0)', 'Comment (1)', 'Comments (%)' ); ?></a></div>
   
       			<?php endif; ?>
       			</div>
       	</div><!-- close .entry-content-->
        </div> <!-- closes the first div box -->
   
        <?php endwhile; ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Multiple get_template_part’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Gaxas](https://wordpress.org/support/users/gaxas/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/multiple-get_template_part/#post-3591811)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
