Wordpress未定义属性:stdClass :: $ post_type

时间:2009-12-11 19:26:22

标签: php wordpress

我在我的博客上收到此错误,有人有同样的错误吗?我该如何修复错误? 我没有编辑过任何文件。

  Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105

  Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/link-template.php on line 112

  Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105

  Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/link-template.php on line 112

  Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105

  Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/link-template.php on line 112
  Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105

  Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/link-template.php on line 112


  Notice: Undefined property: stdClass::$post_type in /home/a4673438/public_html/wp-includes/link-template.php on line 105


  Notice: Undefined property: stdClass::$post_status in /home/a4673438/public_html/wp-includes/link-template.php on line 112

导致此错误的代码 第112行

if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
    $unixtime = strtotime($post->post_date);

第105行

if ( $post->post_type == 'page' )
        return get_page_link($post->ID, $leavename, $sample);

1 个答案:

答案 0 :(得分:0)

尝试在该文件中行#100之后添加

if($post == null) {
    return '';
}

这可能会修复错误,但可能会导致页面出现副作用。准确地说,错过了与帖子的永久链接。

你使用的是什么版本的WordPress?