我正在尝试将帖子分为2列。第一个和左边的将是帖子内的任何图像,第二个和右边的将是the_content()
(不包括图像)。
因此,到目前为止,我可以轻松提取所有图像。但是-我似乎无法获得图像标题,标题或描述。
这是我的代码:
<?php if ( $images = get_posts(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'ASC',
'post_mime_type' => 'image',
)))
{
foreach( $images as $image ) {
$attachmenturl = wp_get_attachment_url($image->ID);
$attachmentimage = wp_get_attachment_image_src( $image->ID, full );
$imageDescription = apply_filters( 'the_description' , $image->post_content );
$imageTitle = apply_filters( 'the_title' , $image->post_title );
$i++;
if (!empty($imageTitle)) {
echo '<div class="client-img-item ci-'.$count++.'"><img src="' . $attachmentimage[0] . '" alt="'.$imageTitle.'" /> <div class="CAPS client-img-caption"><span class="red arrow-lrg">»</span> '.$imageDescription.'</div></div><div class="sml-dots"></div>';
} else { echo '<img src="' . $attachmentimage[0] . '" alt="" />' ; }
}
} else {
echo 'No Image Found';
}?>
wp_prepare_attachment_for_js( $attachment )
将达到目的:)