Restrict number of recent posts in the TAB

0

I have in home a module that displays recent posts , one being featured and three in the module browser, totaling 4 posts. After I started creating more posts, I messed up the module. How can I restrict to appear only 4 posts? Being one featured and three in navigation?

<div id="latest-posts">
    <div class="tab-container">
        <?php
            $displayposts = new WP_Query();
            $displayposts->query(have_posts());
            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>
    
asked by anonymous 22.08.2016 / 22:09

1 answer

0

Without getting into the merits of paging, you can limit the number of posts your query returns through

$displayposts = new WP_Query('posts_per_page' => 4);
    
23.08.2016 / 19:34