WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use a Nivo slider to cycle through the children of a parent page one by one, how can I do that?

I have the following piece of code that grabs ALL the children of a parent page and displays them:

<?php $pages = get_pages(array('child_of' => $post->ID));
foreach($pages as $post)
$fields = get_fields(); ?>
    <?php echo $fields->title; ?>
<?php } wp_reset_query(); ?>

Is there a way to show 1 child image and upon clicking the next arrow on the Nivo it shows the next child image?

share|improve this question
up vote 1 down vote accepted

To get attached (i.e. child) images of a post, try using get_children(). e.g.:

$child_image_args = array(
    'post_mime_type' => 'image',
    'post_parent' => $postID,
    'post_type' => 'attachment'

$child_images = get_children( $child_image_args );

Which returns an associative array of child images. Then, just loop through them, e.g. using wp_get_attachment_image(), to output. e.g.:

<div id="nivoslider">
    foreach ( $child_images as $child_image ) {
        wp_get_attachment_image( $child_image->ID );

Nivo Slider integration is mostly out of scope for WPSE, but if you want to advance manually, change the manualAdvance setting to manual in your #nivoslider jQuery instantiation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.