0

I'm sorry if this is a already asked Question but i'm trying to get my custom post types displayed in grid like this:

<div class="row>
     <div class="col-md-4>
         /* Start the Loop */
         while (have_posts()) : the_post();
         get_template_part('template-parts/post/content', get_post_format());
         endwhile; // End of the loop.
     </div>
</div

that mean i would like to Display every post in a div with the class col-md-4

2 Answers 2

0

You'll want to move the row/columns inside the loop to do this. Perhaps even inside the template part. Seeing as I don't know what's in there, I'd suggest this: (notice I corrected your missing " at the end of div classes and added php start/stop)

<div class="row">
<?php
     /* Start the Loop */
     while (have_posts()) : the_post();
       echo '<div class="col-md-4">';
       get_template_part('template-parts/post/content', get_post_format());
       echo '</div>';
     endwhile; // End of the loop.
?>
</div>

this is fine if there are only 4 items in your row. or your system handles row calculations for you. If it doesn't you'll need to move the row call into the loop as well and add item count and then if statements for the 1st and every 4th item after that.

0
0

The Thing is that i was trying to Display only the thumb and the title of the post inside the thumb with a "got to this Portfolio" button.

Something like this:

        <div class="portfolio">
            <div class="row">
            <?php
                $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 10 );
                $loop = new WP_Query( $args );
                while ( $loop->have_posts() ) : $loop->the_post();
                    echo '<div class="col-md-4">';
                    the_title();
                    //here the thumb
                    //Here the "Go to Portfolio" Button
                    echo '</div>';
                endwhile;
            ?>
            </div>
        </div>
2
  • ask as a new question and post link for me
    – rudtek
    Commented Nov 1, 2018 at 15:53
  • link here you go
    – MisterLA
    Commented Nov 1, 2018 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.