Support » Themes and Templates » break in previous posts

  • Greetings all. I’m currently sing the below code to display the ten previous posts on the frontpage of my site:


    <?php $first=0; ?>
    <?php rewind_posts(); ?>
    <?php $my_query = new WP_Query('showposts=11'); ?>

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <?php $comments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = '$post->ID'"); ?>
    <?php if (in_category($asides_cat)) {continue;} ?>
    <?php if ($first == 0) { $first++; continue;} ?>
    <?php if ($first > 12) {break; } ?>

    • <span class="time"><?php the_time('d M y'); ?></span>
      " rel="bookmark"><?php the_title(); ?>
      <span class="misc">Listed in <?php the_category(' and '); ?> with "><?php comments_number('no', 'one', '%'); ?> comments.</span>
    • <?php
      $words = get_the_content('', 0, '');
      if ($words) {
      $post = strip_tags($words);
      $post = explode(' ', $post);
      $totalcount = count($post);
      } else {
      $totalcount=0;
      }
      ?>

      <?php $first++; ?>
      <?php endwhile; ?>

      What I would like to do, is after the fifth post, add some unrelated content before continuing with the rest of the older posts, can I do this easily using the code I have now, or is a rewrite in order?

      Regards
      Stuart.

  • The topic ‘break in previous posts’ is closed to new replies.