I have the following code to grab the thumbnail images from the posts.
<?php
$attachments = get_children("post_parent={$post->ID}&post_type=attachment&post_mime_type=image&numberposts=1");
foreach ( $attachments as $att_id => $attachment) {
echo wp_get_attachment_image($att_id, 'thumbnail');
}
?>
That works great. But I need to remove / not display / hide the "Title" of the image. So that when someone does a mouse over on the image it won't display the "title" as a pop-up.
Any ideas?
Figured it out.
Based on this post I changed my code to this.
<?php
$featured_image = array();
$args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'post_status' => null,
'orderby' => ID,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$featured_image = wp_get_attachment_image_src($attachment->ID, $size='thumbnail', $icon = false);
}
}
echo '<img src="' . $featured_image[0] . '" alt=""/>';
?>
CrunchyToast420
Member
Posted 3 years ago #
Also, in 2.9.2 you can open up media.php and comment out line 565.
//'title' => trim(strip_tags( $attachment->post_title ))