我正在使用Meta Box plugin, 一切正常。我正在使用它在一些自定义帖子类型上创建图库功能,并且我能够使用以下代码显示上载的图像:
global $wpdb;
$meta = get_post_meta( get_the_ID(), \'meta_key\', false );
if ( ! is_array( $meta ) )
$meta = ( array ) $meta;
if ( ! empty( $meta ) )
{
$meta = implode( \',\', $meta );
$images = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts}
WHERE post_type = \'attachment\'
AND ID IN ( {$meta} )
ORDER BY menu_order ASC" );
foreach ( $images as $att )
{
// Get image\'s source based on size, can be \'thumbnail\', \'medium\', \'large\', \'full\' or registed post thumbnails sizes
$src = wp_get_attachment_image_src( $att, \'full\' );
$src = $src[0];
// Show image
echo "<img src=\'{$src}\' />";
}
}
显示图像,但我还想显示每张图片的标题。我该怎么做?