Support » Themes and Templates » get_children issues

  • Resolved funkycamel


    I’ve got a portfolio section that has a slide show populated with images from the post gallery. The code I use to pull these images in is:

    $first_image = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 1 ) );
    if ( $first_image ) :
    	foreach($first_image as $image) {
    		$img_src = wp_get_attachment_image_src( $image->ID, $size_name );
    		$slider_height = $img_src[2] ;
    $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); ?>

    This works fine on this page

    but when I edit a recent post plugin to also have a running slide show. It pulls in all the images from the media library and not just the ones associated with that post. I’m using exactly the same code as above. Here’s an example :

    If you look at the recent posts at the bottom of the sidebar you will see all images being pulled in.

    Any help/advice would be greatly appreciated

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘get_children issues’ is closed to new replies.