wordpress php登陆/登出字样切换问题

  <?php if(is_user_logged_in())
  {
  echo '<a href="http://blog.hundunstar.com/login/" title="登入">登陆</a>';
  }
  else
  {
  echo '<a href="'.wp_logout_url().'" title="登出">注销?</a>';
  wp_safe_redirect( 'http://blog.hundunstar.com/' );
  }

?>
这段代码添加在了wordpress主题的sidebar.php里面,但是每次不管有没有登陆,都只有注销字样,怎么回事?而且那个重定向也没有任何用

is the function is_user_logged_in() always return true