Restrict number of recent TAB posts

Asked

Viewed 37 times

0

I have in the home a module that displays posts recent, one featured and three in the module browser, totaling 4 posts. After I started creating more posts, messed up the module. How can I restrict to appear only 4 posts? One being 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>

1 answer

0


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

$displayposts = new WP_Query('posts_per_page' => 4);

Browser other questions tagged

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