For some reason the functions I’m using for pulling post images/attachments isn’t working after updating to 3.9, has something changed in the way we pull attachments?
The code I’m using in single.php
<?php
$attachments = get_children(
array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
));
if(count($attachments) > 1) { ?>
<div id="slider" class="flexslider marB18">
<?php ct_status(); ?>
<ul class="slides">
<?php ct_slider_images(); ?>
</ul>
</div>
<div id="carousel" class="flexslider">
<ul class="slides">
<?php ct_slider_images(); ?>
</ul>
</div>
<?php } else {
ct_first_image_lrg();
} ?>
Image functions:
/*-----------------------------------------------------------------------------------*/
/* Get the first image attached to the current post */
/*-----------------------------------------------------------------------------------*/
function ct_get_post_image() {
global $post;
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
if ($photos) {
$photo = array_shift($photos);
return wp_get_attachment_url($photo->ID);
}
return false;
}
/*-----------------------------------------------------------------------------------*/
/* Display first image large */
/*-----------------------------------------------------------------------------------*/
function ct_first_image_lrg() {
$photo = ct_get_post_image();
if ($photo) { ?>
<a href="https://wordpress.stackexchange.com/questions/143720/<?php the_permalink(); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo ct_get_post_image() ?>&w=945&zc=1" />
</a>
<?php }
}
/*-----------------------------------------------------------------------------------*/
/* Display all images attached to listing */
/*-----------------------------------------------------------------------------------*/
function ct_slider_images() {
$photos = ct_get_images('full');
if ($photos) {
foreach ($photos as $photo) { ?>
<li data-thumb="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&w=500&zc=1">
<img class="photo" src="<?php echo get_template_directory_uri(); ?>/img_resize/timthumb.php?src=<?php echo $photo ?>&h=400&w=945&zc=1" title="<?php the_title(); ?>" />
</li>
<?php }
}
}