Support » Fixing WordPress » Standard loop oly returning one page

  • 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

Viewing 4 replies - 1 through 4 (of 4 total)
  • In wp dashboard go to:
    Settings- Reading – Blog pages show at most – select as many as you want

    Josh

    (@josh401)

    Moderator and Editor Customizer

    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 😉

    @josh: just wanted to write the same thing you did in your edit 😉

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Standard loop oly returning one page’ is closed to new replies.