【发布时间】:2015-06-19 10:22:18
【问题描述】:
我正在尝试获取存储在 WordPress 图像标题中的文本。我有代码可以将图像附加到帖子中,并且我可以稍后在页面中显示它们。
这就是将图片附加到帖子的原因。
<?php
if ($attachments = get_children(array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
)));
foreach ($attachments as $attachment) {
$mynewarray = wp_get_attachment_image_src($attachment->ID, 'full');
$anotherarray [] = $mynewarray[0];
} ?>
这会显示每个图像,我只是将 [2] 更改为调用不同的图像。
<?php echo $anotherarray[2]; ?>
一切正常,但我想将文本存储在标题中,几个月前我开始这样做,花了几天时间试图获得标题,现在放弃了,现在才回来。如此迷失,感谢任何帮助。
感谢您的建议,但还没有任何效果,我认为这是因为我将附加到帖子的所有图像称为数组。然后使用数组部分将图像设置为div的背景。帖子中列为微笑问题的方法在这种情况下不起作用。
【问题讨论】: