• I repeat this code like five times, in order to get post from different categories(with the default query), it works perfect, but i would like to know if this is a good practice or should i create DIFFERENT QUERIES, which method is faster???

    <div id="cat1" class="content">
    <?php $limit=0; ?>
     <?php if ( have_posts() ) : ?>
      <?php while ( have_posts() ) : the_post(); ?>
      <?php if ($limit < 3) : ?>
      <?php if(has_category(8)) {get_template_part( 'content', 'categorypost' );$limit++; } ?>
       <?php endif;?>
      <?php endwhile; ?>
      <php endif;?>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Queries can be one of the slowest operations, so it is usually best to limit them where possible.

    Thread Starter Diogo15

    (@diogo15)

    Thanks for your reply, but did no answer my question, in this way i am not creating a new query i am just re-reading the default query..

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Awesome or awful QUERY CODE??’ is closed to new replies.