我已将一些图片上传到帖子中,并在&#34中添加了标题;上传到此帖子"图。
使用get_children()访问它们时,无法找到标题。无法通过post数组(如摘录或标题),wp_get_attachment_metadata(),get_post_meta()或get_post_custom()在数据库(wp_postmeta)中找到它们。
当我在管理界面重新加载帖子并重新访问添加媒体界面时,保存的标题显然会保存,因为他们在使用"上传到此帖子时仍会显示。"但是,当使用"所有媒体项目进行过滤时,"或通过媒体菜单查看。
存储此数据的任何想法,以及访问它的内置方式?
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
print_r($images);
if (count($images) <= 1) {
the_post_thumbnail('portfolio-1column', array('alt' => get_the_title(), 'class' => 'shadow'));
}
else
{
?>
<ul class="bxslider" id="bxslider_article">
<?php
$i=0;
foreach ($images as $image_id => $image) {
$img_file = wp_get_attachment_image_src($image_id, 'portfolio-1column');
?>
<li>
<img src="<?php echo $img_file[0]; ?>" title="pic<?php echo $i; ?>" /></li>
<?php
$i++;
}
?>
</ul>
<?php
}
}
这就是我得到的:
Array (
[842] => WP_Post Object (
[ID] => 842 [post_author] => 1
[post_date] => 2014-07-16 09:07:13
[post_date_gmt] => 2014-07-16 07:07:13
[post_content] =>
[post_title] => 20140525_184556(2)
[post_excerpt] =>
[post_status] => inherit
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => 20140525_1845562-2
[to_ping] =>
[pinged] =>
[post_modified] => 2014-07-16 09:07:13
[post_modified_gmt] => 2014-07-16 07:07:13
[post_content_filtered] =>
[post_parent] => 646
[guid] => http://pal.localhost/wp-content/uploads/2014/07/20140525_18455621.jpg
[menu_order] => 0
[post_type] => attachment
[post_mime_type] => image/jpeg
[comment_count] => 0
[filter] => raw )
[843] [...] ) )