0

Need some guidance. I am creating a custom grid for a blog. So for example block 3 and 5 are bigger etc...

But for this to happen after else: i need to have two blogs in that one area so will be two in that one block.

Anyone done anything similar? who can share?

Attached is my code.

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

            <?php if ($wp_query->current_post  == 2): ?>

                <div class="col5x2">
                    <?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); ?>
                    <div class="col s12 m7 l7" style="background-image: url(<?php echo $thumbnail[0]; ?>);">
                    </div>
                    <div class="col s12 m5 l5">
                        <div class="text">
                            <h1><?php the_title(); ?></h1>
                            <?php the_excerpt(); ?>

                            <p><a href="<?php the_permalink(); ?>" class="btn">read more top</a></p>
                        </div>
                    </div>
                </div>


            <?php else: ?>

                <div class="col5">


                    <div class="item">
                        <div class="date">
                            Date: <?php echo get_the_date('jS F Y');?>
                        </div>
                        <div class="image">
                            <?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); ?>
                            <img src="<?php echo $thumbnail[0]; ?>">
                        </div>
                        <div class="text">

                            <h2><?php the_title(); ?></h2>
                            <?php the_excerpt(); ?>
                            <p><a href="<?php the_permalink(); ?>" class="btn">read more 1</a></p>
                        </div>
                    </div>

                    <div class="item">
                        <div class="date">
                            Date: <?php echo get_the_date('jS F Y');?>
                        </div>
                        <div class="image">
                            <?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" ); ?>
                            <img src="<?php echo $thumbnail[0]; ?>">
                        </div>
                        <div class="text">

                            <h2><?php the_title(); ?></h2>
                            <?php the_excerpt(); ?>
                            <p><a href="<?php the_permalink(); ?>" class="btn">read more 1</a></p>
                        </div>
                    </div>



                </div>

            <?php endif ?>

            <?php comments_template( '', true ); ?>

        <?php endwhile; ?>
0

Changes it so it works.

<?php 

        $i = 1;
        $icount = 1;

        ?>


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

            if ($icount < 11) {


                if ($i % 5 == 0) {


                    echo '<div class="col5x2">';

                    include 'modules/projects/small-square.php'; 

                    echo '</div>';

                    $i = 1;
                    $icount++;

                    continue;
                }

                if($i % 2 == 1):

                    echo '<div class="col5">'; 

                    endif;

                    include 'modules/projects/small-square.php'; 
                    echo $icount;

                    if($i % 2 == 0):

                    echo '</div>';

                endif;

                $i++; $icount++;

            } else{



                if ($icount == 21) {


                    echo '<div class="col5x2">';

                    include 'modules/projects/small-square.php'; 

                    echo '</div>';

                    $i = 1;
                    $icount = 1;

                    continue;
                }

                if($i % 2 == 1):

                    echo '<div class="col5">'; 

                    endif;

                    include 'modules/projects/small-square.php'; 
                    echo $icount;

                    if($i % 2 == 0):

                    echo '</div>';

                endif;

                $i++; $icount++;


            }


            ?>




            <?php comments_template( '', true ); ?>

        <?php endwhile; ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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