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

  • SEARCH
  • Home
  • 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 1059029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:06:43+00:00 2026-05-16T18:06:43+00:00

i am trying to get wordpress posts, 3 at a time, this is the

  • 0

i am trying to get wordpress posts, 3 at a time, this is the code i’m using:

            <?php while ( have_posts() ) : the_post() ?> 
<?php  if(get_post_meta($post->ID, 'feature', true) != true) {; ?>
         <div class="show_col">
  <?php   for ($i = 1; $i <= 3; $i++) { ?>

<div class="set">
<a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"> 
<img class="image" src="http://localhost/portpress/wp-content/themes/myTemp/portfolio/<?php echo get_post_meta($post->ID, 'intro_thump', true); ?>.jpg" width="300px" alt="AUREL #<?php the_ID(); ?>" />
</a>    
<?php the_content("<P class='more'> Read More &#187; </p>"); ?>

</div>
<?php };  ?>
</div>           

<?php  }; ?>
<?php endwhile; ?>  

i know this loop is echoing ONE post THREE times – but what i really want is this end result

 <div class="show_col">
      <div class="show_col"> post1  </div>
      <div class="show_col"> post2  </div>
      <div class="show_col"> post3  </div>
 </div>
<div class="show_col">
      <div class="show_col"> post4  </div>
      <div class="show_col"> post5  </div>
      <div class="show_col"> post6  </div>
 </div>
<!-- and so on -->

i am doing this as the height of each post varies – therefore i add something like
.show_col{clear:both} so that the next three posts go under neath

i hope you could help

thanks

  • 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-05-16T18:06:44+00:00Added an answer on May 16, 2026 at 6:06 pm

    This is the code you need (I corrected some of your syntax):

    <?php $i = 0; ?>
    <?php while ( have_posts() ): the_post();?> 
        <?php  if(get_post_meta($post->ID, 'feature', true) != true): ?>
        <div class="show_col">
    
            <?php if(($i%3) == 0): ?>
                </div>
                <div class="show_col">
            <?php endif;?>
    
            <div class="set">
            <a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"> 
            <img class="image" src="http://localhost/portpress/wp-content/themes/myTemp/portfolio/<?php echo get_post_meta($post->ID, 'intro_thump', true); ?>.jpg" width="300px" alt="AUREL #<?php the_ID(); ?>" />
            </a>    
            <?php the_content("<P class='more'> Read More &#187; </p>"); ?>
    
            </div>
    
        </div>           
    
        <?php  endif; ?>
    <?php $i++; ?>
    <?php endwhile; ?> 
    

    Also you seem to add a semicolon after closing the function ( }; ), don’t do that, there is no need for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a wordpress newbie trying to add dynamic posts and pages through get requests.
Im trying to get a list of posts from WordPress for the last 7,30
In Wordpress, I'm trying to add the post ID of posts I publish in
So I am using AnythingSlider in Wordpress. This is why I am trying to
I'm having hard time trying to use teasers post in my wordpress theme (based
This is a wordpress question. I am trying to use a bit of code
I am trying to get a WordPress image to change based on which tab
I'm trying to get infinite scroll to work with masonry on a WordPress install,
WordPress has been installed as a blog into osCommerce. I'm trying to get the
I'm trying to define a new shortcode in WordPress, and I get the following

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.