Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从上传到Wordpress post的图像中获取标题_Php_Wordpress_Image_Attachment_Caption - Fatal编程技术网

Php 从上传到Wordpress post的图像中获取标题

Php 从上传到Wordpress post的图像中获取标题,php,wordpress,image,attachment,caption,Php,Wordpress,Image,Attachment,Caption,我已经上传了一些图片到一篇文章,在上传到这篇文章视图中添加了标题 当使用get_儿童访问它们时,无法找到标题。在数据库wp_postETA中找不到它们,也不能通过post数组作为摘录或标题、wp_get_attachment_元数据、get_post_meta或get_post_自定义 当我在管理界面中重新加载帖子并重新访问添加媒体界面时,保存的标题显然会被保存,因为在使用上载到此帖子进行过滤时,它们仍然会显示。但是,当使用所有媒体项进行过滤或通过“媒体”菜单查看时,则不会出现这种情况 是否知道

我已经上传了一些图片到一篇文章,在上传到这篇文章视图中添加了标题

当使用get_儿童访问它们时,无法找到标题。在数据库wp_postETA中找不到它们,也不能通过post数组作为摘录或标题、wp_get_attachment_元数据、get_post_meta或get_post_自定义

当我在管理界面中重新加载帖子并重新访问添加媒体界面时,保存的标题显然会被保存,因为在使用上载到此帖子进行过滤时,它们仍然会显示。但是,当使用所有媒体项进行过滤或通过“媒体”菜单查看时,则不会出现这种情况

是否知道这些数据存储在哪里,以及访问这些数据的内置方式

$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
    }

                                                    }

正如我所说,无论是通过post数组作为摘录还是通过标题-$post->post_摘录都是空的。您说的是作为摘录-显示您的代码更好,因为post_摘录与摘录不同。在$post上打印以检查您的帖子是否正确$img=获取发布获取发布缩略图id;还应该尝试,然后执行$img->post_摘录。现在添加代码示例。很抱歉我知道我有正确的post ID,子项也是正确的项。我唯一的建议是,这是一个自定义post类型,构建数组的函数不会返回摘录。追踪这一点的最佳方法是查看创建帖子的php文件,并查看它是否是使用自定义名称创建的。另一件要尝试的事情是搜索数据库中的值,您知道该值不是用于post_摘录,而是用于值字段中的实际post-可能它被保存为不清楚的内容!
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] [...] ) )