PHP警告:非法字符串偏移'width','height'(WordPress调试)

时间:2018-01-22 17:52:00

标签: php wordpress debugging

在过去的几天里,当我做某些事情时,我的WordPress安装一直挂起,包括:

  1. 尝试访问我的媒体库
  2. 尝试管理我的插件
  3. 指示WP Fastest Cache插件清空网站缓存
  4. 等等 - 如此清楚 - 这是一个更广泛的问题。

    当然,我咨询了网站错误日志,其中包含:

    [22-Jan-2018 15:57:54 UTC] PHP Warning:  Illegal string offset 'width' in /home/ptrcao/public_html/wp-content/themes/independent-publisher/image.php on line 26
    
    [22-Jan-2018 15:57:54 UTC] PHP Warning:  Illegal string offset 'height' in /home/ptrcao/public_html/wp-content/themes/independent-publisher/image.php on line 27
    

    image.php的第26行和第27行对应于下面显示的上下文中的$metadata['width']$metadata['height']

                            <?php
                            $metadata = wp_get_attachment_metadata();
                            printf(
                                __( '"%1$s" - <a href="%2$s" title="Link to full-size image">%3$s &times; %4$s</a> %5$s <a href="%6$s" title="Return to %7$s" rel="gallery">%7$s</a>', 'independent-publisher' ),
                                get_the_title(),
                                wp_get_attachment_url(),
                                $metadata['width'],
                                $metadata['height'],
                                independent_publisher_entry_meta_category_prefix(),
                                get_permalink( $post->post_parent ),
                                get_the_title( $post->post_parent )
                            );
                            ?>
    

    任何人都可以对解决方案有所了解吗?

0 个答案:

没有答案