Displaying x random child pages
-
Hi everbody,
I’d like to display 3 random pages as a kind of excerpt (‘this pages could be interesting for you’). It works that WordPress displays me one random child page.But I’d like to display 3 pages. This is my code:
<?php if (2 == $post->post_parent or 2 == $post->ID) { $parent = 2; } elseif (7 == $post->post_parent or 7 == $post->ID) { $parent = 7; } elseif (10 == $post->post_parent or 10 == $post->ID) { $parent = 10; } $args=array( 'child_of' => $parent, 'number' => 3 ); $pages = get_pages($args); shuffle($pages); if ($pages) { $pageids = array(); foreach ($pages as $page) { $pageids[]= $page->ID; $content = $page->post_excerpt; $content = apply_filters( 'the_excerpt', $content ); } } ?>
The ‘number’ => 3 does not work and I have no idea why… Can somebody help me please?
Greetings from Germany,
Raisis
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Displaying x random child pages’ is closed to new replies.