简体   繁体   中英

Create a full-width post every 4 post grids - Wordpress Loop

How can I create a full-width post every 4 post grids? As in the following picture.

在此处输入图片说明

Here is my code wordpress loop.

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

    <article id="post-<?php the_ID(); ?>" <?php post_class('col-sm-6 grid-item '); ?>>

        <div class="entry-image">
            <a href="<?php echo get_permalink() ?>"><?php the_post_thumbnail('grid-thumb'); ?></a>
            <?php unbranded_entry_footer(); ?>
        </div>

        <header class="entry-header">
            <?php
            the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );

            if ( 'post' === get_post_type() ) : ?>
            <div class="entry-meta">
                <?php unbranded_posted_on(); ?>
            </div><!-- .entry-meta -->
            <?php
            endif; ?>
        </header><!-- .entry-header -->

        <div class="entry-content">
            <p><?php echo unbranded_string_limit_words(get_the_excerpt(), 18); ?>&hellip;</p>
        </div><!-- .entry-content -->
    </article>

<?php endwhile; endif; ?>

May I know are you using visual composer or creating custom template? If using visual composer you can do it from back-end or place the condition to disable the sidebar from right using above the sidebar in page.php

<?php if(!is_page('your-page-slug' or ID)) { ?>

/*sidebar code*/

<?php } ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM