Help optimising homepage loop

Question

Is there a better way to do my homepage loop? I’m using 3 template parts to display 3 sections (3 recent posts excluding category, 3 recent posts from excluded category and then 12 posts starting from post 4 excluding a category)

Any help would be appreciated

<?php query_posts('cat=-200&posts_per_page=3'); ?>

  <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post(); ?>

      <?php get_template_part( 'template-parts/content-top'); ?>

    <?php endwhile; ?>

  <?php else : ?>

    <?php get_template_part( 'template-parts/content', 'none' ); ?>

  <?php endif; ?>

  <?php query_posts('cat=200&posts_per_page=2&offset=1'); ?>

  <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post(); ?>

      <?php get_template_part( 'template-parts/content-middle'); ?>

    <?php endwhile; ?>

  <?php else : ?>

    <?php get_template_part( 'template-parts/content', 'none' ); ?>

  <?php endif; ?>
  <?php query_posts('cat=-200&posts_per_page=12&offset=3'); ?>

<?php if ( have_posts() ) : ?>

  <?php while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'template-parts/content-bottom'); ?>

  <?php endwhile; ?>

<?php else : ?>

  <?php get_template_part( 'template-parts/content', 'none' ); >

<?php endif; ?>
0
Kamboodle 3 years 2019-10-31T04:35:44-05:00 0 Answers 46 views 0

Leave an answer

Browse
Browse