Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:39:44+00:00 2026-06-18T12:39:44+00:00

<?php get_header(); ?> <div class=page-wrap group> <div class=grid> <?php query_posts(‘showposts=6’); ?> <?php if (have_posts()):

  • 0
<?php get_header(); ?>
<div class="page-wrap group">

<div class="grid">

  <?php query_posts('showposts=6'); ?>

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

  <section class="blog-posts col-2-3 grid-pad">

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

      <article class="module" id="post-<?php the_ID(); ?>">

        <h2> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a </h2>
        <p><time datetime="2001-05-15 19:00"><?php echo date('l jS F Y')?></p>

        <?php the_excerpt(); ?>


      </article>

      <?php endwhile; ?>

  </section>

This is my code for the index.php, what I want to do is have lets say 3 blog posts in <section class="blog-posts col-2-3 grid-pad"> then another 3 posts in <section class="blog-posts col-2-3 grid-pad">

So how do you loop the posts so you can have them spread across the page? Right now I can only get it so it displays them all in the first

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:39:45+00:00Added an answer on June 18, 2026 at 12:39 pm

    Simply use a counter variable:

    <?php if (have_posts()): ?>
    
      <section>
    
      <?php $i = 0; while (have_posts()) : the_post(); ?>
    
          <article>
          ...
          <article>
    
      <?php if(++$i === 3): // close previous and open new one ?>
      </section>
    
      <section>
      <?php endif; ?>      
    
      <?php endwhile; ?>
      </section>    
    
    <?php endif; ?>
    

    Or you can perform two queries with the WP_Query class, with the posts_per_page=3 argument, and the offset=3 argument on the 2nd query.


    To change the number of posts displayed on your page, add this to your functions file:

    add_action('pre_get_posts', function($query){
    
      if(is_admin() || !$query->is_main_query())
        return;
    
      if(is_home()) // or whatever page you want the limit applied to
        $query->set('posts_per_page', 6);
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php /** * Template Name: Blog page * Description: The blog page */ get_header();
<?php get_header(); ?> <div id=content> <?php if (have_posts()): ?> <?php $i=0;?> <?php while (have_posts())
in wordpress in search.php I have this.. get_header(); ?> ...html/css <?php if ( have_posts()
I'm using the below code on index.php file of twentyeleven get_header(); ?> <div id=primary>
here is my blog page template: <?php /** * Template Name: Blog * *
I can't get PHP to recognize the ImageMagick (Imagick) class. Everything else works, the
I use a template that generates thumbnails on the content.php page like so: <article
Alright so I have a custom page template designed with javascript and php (lets
I am looking for a method to amend my Blog page in order that
So this is the basic template page code: <?php /* * Template name: About

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.