numberposts is not working for me (2 posts)

  1. phpchick
    Posted 1 year ago #

    // args
    $args = array(
    	'numberposts' => 3,
    	'post_type' => 'earnings',
    	'meta_key' => 'article_category',
    	'meta_value' => 'Immediately Actionable'
    // get results
    $the_query = new WP_Query( $args );
    // The Loop
    <?php if( $the_query->have_posts() ): ?>
    	<ul class="frontnewsul">
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<li class="frontnewsli">
    			<a href="<?php the_permalink(); ?>"><div class="stksymnewshdln"><?php the_field('symbol'); ?></div><span class="frontnewslink"><?php the_title(); ?></span></a>
    	<?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>

    The number of posts that is shown is ALL of them, rather than the 3 that I would like. Can anybody help out on this? I have this snippet of code on the front page. There are other loops going on in the front-page, not sure if that has anything to do with it.

  2. Dave Naylor
    Posted 1 year ago #

    Use posts_per_page

Topic Closed

This topic has been closed to new replies.

About this Topic