I am hoping someone can assist, as this is killing me. I’m working with someone elses code and having lots of trouble and I’m only new at wordpress.
What I want to acheive is for the post to display the first image from the gallery at the top of the page, then the second image below it (next to some text content), then under that I want it to display all the remaining images in the gallery. For some reason, it’s currently leaving the last two images in the gallery out, as though they are being intentionally excluded. Thanks so much for your help I appreciate it.
This is the current code:
<?php
get_header();
if (have_posts()) {
while (have_posts()) {
the_post();
$images = GetPostImages(); // Get Post Images
$tags = GetPostTags(); // Get Post Tags String
?>
<div class="project">
<img src="<?php echo $images[1]->guid; ?>" class="large" width="1000" height="700" />
<div class="projectdesc">
<h1><?php the_title(); ?></h1>
<p class="tags"><?php echo $tags; ?></p>
<?php
the_content(); ?>
</div>
<img src="<?php echo $images[2]->guid; ?>" class="right" width="600" height="400" />
<?php
// Additional Project Images
for ($i = 3; $i < count($images); $i++) {
?>
<img src="<?php echo $images[$i]->guid; ?>" class="large" width="1000"/>
<?php
}
?>
</div>
<?php
}
}
get_footer();
?>`
The code in the functions.php file is also below. I think this controls the way the post page processes images?
function GetPostImages() {
global $post;
// Get image attachments
$images = get_children('post_type=attachment&post_mime_type=image&post_parent='.$post->ID);
// Sort by menu_order
foreach ($images as $key=>$image) {
$newImages[$image->menu_order] = $image;
}
// Return
return $newImages;
}
use wp_get_attachment_image_src() to get the image source
witin the functions.php file or an include file within the functions.php include…