Home › Forums › Back End › WordPress: Preload next post images › Re: WordPress: Preload next post images
March 23, 2011 at 12:40 pm
#54430
infocentre
Member
I figured it is a pretty tall ask – but there must be a way of gathering the Next post ID and it’s attached Featured image/images.
I did come across this which is kind of on the right lines:
function twpw_imagepreload() {
$args3=array(
'post_status'=>'publish'
);
$imageloader= null;
$imageloader = new WP_Query();
$imageloader->query($args3);
$imagepreload.='';
if ($imageloader->have_posts()) : while ($imageloader->have_posts()) : $imageloader->the_post();
$parentid=get_the_ID();
$args1=array(
'post_type'=>'attachment',
'post_parent' => $parentid,
'post_mime_type' => 'image'
);
$image_query = get_children($args1);
foreach ( $image_query as $attachment_id => $attachment ) {
$image3=wp_get_attachment_image_src($attachment_id);
$imagepreload.='';
}
endwhile; endif;
$imagepreload.='';
return $imagepreload;
}
It’s purpose is to load ALL attached images, but it times stops after loading the first 6 (i think), not sure why.
Any other suggestions as to how i could achieve this, or something similar?