Question

I made a grid blog layout on my wordpress site and i got some help from a friend with some code. It shows 3 posts per row but it wont go past 2 rows so its only showing 6 posts when there is much more. I know I need to expand on my code to allow this but I'm not really sure how. Here is what I have currently for my single.php file

<?php get_header(); ?>   

    <div class="page-header">
        <div class="container">
        </div>
    </div>
<div class="page-header2">
<h1> - Remodeling 101 - </h1>
</div>
<div class="blog-bg">
  <div class="container">

    <div class="row">

    <?php
    $the_query = new WP_Query("showposts=6&orderby=date");
    $i = 0;
    while ( $the_query ->have_posts() ) {$the_query ->the_post(); $i++;
        if ($i == 1){echo "<div class=row>";}
        ?>
        <div class="col-md-4">
            <article class="post">

                <?php if ( has_post_thumbnail() ): ?>
                    <?php echo the_post_thumbnail();?>
                <?php endif;?>

                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <hr>
                <div class="blog-desc">
                    <p>
                        on <?php echo the_time('l, F jS, Y');?>
                        <a href="<?php comments_link(); ?>"></a>
                    </p>
                    <?php the_excerpt(); ?>
                </div>
            </article>
        </div>
        <?php
        if ($i == 3){echo "</div><div class=row>";}
        if ($i == 6){echo "</div>";}


    }
    wp_reset_postdata();
    ?>


    </div>

  </div>
</div>

<?php get_footer(); ?>
Was it helpful?

Solution

The answer is in your query itself

$the_query = new WP_Query("showposts=6&orderby=date");

showposts attribute is set to 6, change it to the number you prefer.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top