How to remove the featured post from the right column?

Asked

Viewed 73 times

1

Good morning to all, I have a site that I’m moving where the home has a slide of posts, where great appears the post featured and the right side 3 small posts. My problem is that in the column of the 3 posts, also appears the post highlighted, IE, besides it large in the left column, it appears small in the right column. How can I make him not show this same post? Actually, Oss featured post is the last post inserted by my client.

Follows the code:

<div class="featured-posts-wrap">
            <div class="row">
                <div class="col-9 nopadding">
                    <div class="blog-title">
                        <h2>notícias/</h2>
                    </div>
                    <div id="latest-posts">
                        <div class="tab-container">
                        <?php
                            $displayposts = new WP_Query();
                            $displayposts->query('posts_per_page=3');
                            while ($displayposts->have_posts()) : $displayposts->the_post();
                            $tab_number = $displayposts->current_post + 1;            
                        ?>
                        <div id="tab<?php echo $tab_number;?>"class="tab_content">
                            <div class="post clearfix">
                                <?php if ( has_post_thumbnail() ) { ?>
                                <div class="post-image">
                                    <?php the_post_thumbnail(); ?>
                                </div>
                                <?php } ?>
                                <div class="meta-wrap">
                                    <div class="author-wrap"><p><?php the_category(', '); ?></p></div>
                                </div>

                                <div class="post-content">
                                    <div class="post-title">
                                        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                    </div>
                                    <div class="read-wrap"><a href="<?php the_permalink(); ?>">Leia mais</a></div>
                                </div>
                            </div>
                        </div>
                        <?php endwhile; ?>
                        </div>
                        <ul class="nav tabs">
                            <?php
                                while ($displayposts->have_posts()) : $displayposts->the_post();
                                $tab_number = $displayposts->current_post + 1;
                            ?>
                            <li>
                                <div class="meta-wrap">
                                    <div class="author-wrap"><p><?php the_category(', '); ?></p></div>
                                </div>
                                <h2><a href="javascript:void(0);" id="link<?php echo $tab_number;?>"><?php the_title(); ?></a></h2>
                                <div class="read-wrap"><a href="<?php the_permalink(); ?>">Leia mais</a></div>
                            </li>
                            <?php endwhile; ?>
                        </ul>
                    </div>

                </div>

Follow the image of this block for your understanding:

inserir a descrição da imagem aqui

From now on I thank you all for your attention!!

1 answer

0


Test the following code, is the simplest and most effective way to use multiple loops within WP:

<div id="latest-posts">
    <div class="tab-container">
                    <?php
                        $featuredPostArgs = array(
                            'posts_per_page' => 1
                        );
                        $featuredPost = new WP_Query($featuredPostArgs);
                        while ($featuredPost->have_posts()) : $featuredPost->the_post();
                        $tab_number = $featuredPost->current_post + 1;            
                    ?>
                    <div id="tab<?php echo $tab_number;?>" class="tab_content">
                        <div class="post clearfix">
                            <?php if ( has_post_thumbnail() ) { ?>
                            <div class="post-image">
                                <?php the_post_thumbnail(); ?>
                            </div>
                            <?php } ?>
                            <div class="meta-wrap">
                                <div class="author-wrap"><p><?php the_category(', '); ?></p></div>
                            </div>

                            <div class="post-content">
                                <div class="post-title">
                                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                </div>
                                <div class="read-wrap"><a href="<?php the_permalink(); ?>">Leia mais</a></div>
                            </div>
                        </div>
                    </div>
                    <?php endwhile; wp_reset_postdata(); ?> 
                </div>
                <ul class="nav tabs">
                    <?php
                        $featuredPostsArgs = array(
                            'posts_per_page' => 3,
                            'offset' => -1
                        );
                        $featuredPosts = new WP_Query($featuredPostsArgs);
                        while ($featuredPosts->have_posts()) : $featuredPosts->the_post();
                        $tab_number = $featuredPosts->current_post + 1;            
                    ?>
                    <li>
                        <div class="meta-wrap">
                            <div class="author-wrap"><p><?php the_category(', '); ?></p></div>
                        </div>
                        <h2><a href="javascript:void(0);" id="link<?php echo $tab_number;?>"><?php the_title(); ?></a></h2>
                        <div class="read-wrap"><a href="<?php the_permalink(); ?>">Leia mais</a></div>
                    </li>
                    <?php endwhile; wp_reset_postdata(); ?> 
                </ul>
            </div>

I tested on my side and it’s working, confirm it’s working there too :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.