WordPress.org

Ready to get started?Download WordPress

Forums

Standard loop oly returning one page (5 posts)

  1. paulbbird
    Member
    Posted 1 year ago #

    Hi

    I am reading, learning and experimenting with THE LOOP - using my Wamp localhost as the test area.

    I am trying to develop a Page which will display a list of my existing pages.

    I am struggling to understand 2 things:

    1: When I use the standard loop:
    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <? php if ( have_posts() ) : ?>
     <? php while ( have_posts() ) : the_post(); ?>
     <?php the_title();?>
     <?php the_time( 'D  M   Y');?>
     <? php endwhile; ?>
     <? php endif; ?>

    My loop only returns 1 page (the current page)
    When I use the Custom loop using:

    <?php $myPosts = new WP_Query( 'post_type=page' );

    The results are fine and show more than 1 page

    2 The output with the custom loop is limited to 10 items, even though I have 30 published posts and pages - can someone tell me where to look to understand how to get all 30 to appear.

    Thanks
    PAul

  2. Media X
    Member
    Posted 1 year ago #

    In wp dashboard go to:
    Settings- Reading - Blog pages show at most - select as many as you want

  3. In your first example.. you have not set any arguments.

    In your second example.. you are only querying pages and not posts.

    Take a look at this codex article:
    https://codex.wordpress.org/Class_Reference/WP_Query

    EDIT: @MediaX, sorry to keep stepping on your toes ;)

  4. Media X
    Member
    Posted 1 year ago #

    @Josh: just wanted to write the same thing you did in your edit ;-)

  5. paulbbird
    Member
    Posted 1 year ago #

    Hi Josh and Media X

    Thanks for your support - really appreciated.
    (Plus I now know about backticks - soz)

    It's really the first Standard loop which is confusing me - as I can only get it to return 1 page

    The custom loop works ok where I am using the WP_query approach. (I was trying for a list of pages rather than posts)

    Its the arguments bit that is confusing me, even though the article has helped. Can you give me a pointer to where arguments should be set for the get_posts/have_posts approach?

    Thanks again
    Paul

Topic Closed

This topic has been closed to new replies.

About this Topic