WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_children issues (2 posts)

  1. funkycamel
    Member
    Posted 1 year ago #

    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] ;
    	}
    endif;
    
    $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 http://crunch2012.crunchcreates.co.uk/portfolio-2/

    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 :
    http://crunch2012.crunchcreates.co.uk/what-we-do-brand-communications/

    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

  2. funkycamel
    Member
    Posted 1 year ago #

    I've used a work around!

Topic Closed

This topic has been closed to new replies.

About this Topic