• Hi, I’m no WordPress/PHP expert, and I’m using this piece of code with the Twenty Ten theme to show the child pages of a parent page on the front page of my site, but it’s only showing 5 pages instead of the 10 that are there. Anyone know why?

    <div class="options">
    		<ul class="clearfix">
    	<?php $i = 1; ?>
    	<?php
    $post_per_page = 10;
    $args = array(
    		'post_parent' => $post->ID='11',
    		'post_type' => 'page',
    		'post_status' => 'publish',
    		'post_per_page' => $post_per_page
    		);
    		$postslist = get_posts($args);
    		foreach ($postslist as $post) :
    		setup_postdata($post);
    	?>
    			<?php if($i%2 == 0) : ?>
    			<li id="<?php echo $post->post_name; ?>" class="nomarr">
    			<?php else : ?>
    			<li id="<?php echo $post->post_name; ?>">
    			<?php endif; ?>
    		        <?php $i++; ?>
    				<a class="icn" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    				<h2><?php the_title(); ?></h2>
    				<?php echo get_field('description'); ?>
    			</li>
    	<?php endforeach; ?>
    		</ul>
    
             </div>

    Thanks in advance for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • ‘post_per_page’ should be ‘posts_per_page’ (plural)

    If that doesn’t work, add ‘numberposts’ => $post_per_page to your args array?

    John

    Thread Starter adampfoster

    (@adampfoster)

    Hey thanks so much for that!
    Such a little thing missing one character, but it worked a treat!
    Cheers
    Adam

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show child pages on front page using odd/even classes’ is closed to new replies.