• Aaron

    (@gardi)


    Hi.
    Ive made a “post per page ” limitation with category “Actors” based filtering. The problem is, this code checks the last 10 post and show only the ones with the “Actors” on it; which in result shows 3 or 4 posts.

    But i only want to show 10 “Actors” posts rather than the otherway around. Can you please help me?

    <?php
        $loop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 5) );
        while ( $loop->have_posts() ) : $loop->the_post();
         if(get_field('Actors') )
         {
                echo '<li>';
                echo '<a href="';
                the_permalink();
                echo '">';
                the_title();
                echo '</br><span> ';
                the_time('d/m/Y');
                echo '</span></a></li>';
        }else{
                echo '';
        }
            endwhile;
    
        ?>

    Note: “if(get_field(‘Actors’)” is a custom field, and i think this problem is not occuring due to this ( since ive also tried has_term version.)

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrew Bartel

    (@andrew-bartel)

    WP_Query has category filtering

    Thread Starter Aaron

    (@gardi)

    Alright thanks , ive stripped the needless parts now. This is what i got, how can i implement the limitation?

    $loop = new WP_Query('category_name=actors');
    Thread Starter Aaron

    (@gardi)

    By this i mean i still receive 3 post while i should have got 10.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘'posts_per_page' => 10 doesnt show 10 post?’ is closed to new replies.