wordpress错误日志出现Catchable fatal error: Object of class WP_Error could not be converted to string的解决办法

付费节点推荐

免费节点

节点使用教程

最近查看wordpress的错误日志时发现有这样的提示:Catchable fatal error: Object of class WP_Error could not be converted to string,于是苦心搜索找到了解决办法

该问题是因为网页没有分类导致get_category_parents($categories[0]->term_id, TRUE, ' > ')获取错误,于是按照以下方式修改就行了。

将get_category_parents($categories[0]->term_id, TRUE, ' > ')修改为

is_wp_error($cat_parents=get_category_parents($categories[0]->term_id, TRUE, ' > '))?"":$cat_parents)即可

评论(0)
游客的头像
表情
全部评论
最新