管理栏不会出现在 WordPress 网站的前端 [英] Admin bar doesn't appear on the front-end of a WordPress website

查看:48
本文介绍了管理栏不会出现在 WordPress 网站的前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在子域 (http://base.example.com) 中安装了 WordPress,但我希望用户从 (http://www.example.com) 访问前端.子域是站点根目录中的子文件夹.我已将 index.php.htaccess 复制到我网站的根目录,并将 index.php 中的路径更改为指向我的子域.该网站前端和后端都运行良好,但是当我登录并转到前端时,我看不到管理栏,并且好像我已注销.当我转到 wp-admin 时,我看到了管理栏,我可以根据需要执行所有管理功能.如何解决此问题,以便我可以在前端看到管理栏?

I have a WordPress installation in a subdomain (http://base.example.com), but I want users to access the front-end from (http://www.example.com). The subdomain is a subfolder within the root of the site. I have copied index.php and .htaccess to the root of my site and changed the path in index.php to point to my subdomain. The website works fine, both the front-end and back-end, but when I login and go to the front-end, I cannot see the admin bar, and it appears as if I am logged out. When I go to wp-admin, I see the admin bar, and I can preform all administration functions as needed. How do I fix this problem so I can see the admin bar on the front-end?

推荐答案

EDIT 2:

您应该能够使用插件 root Cookie 解决您的问题.它已经 2 年没有更新了,但它会解决您遇到的问题.您需要可以跨子域访问登录/身份验证 cookie.请按照以下说明操作:

You should be able to resolve your issues using the plugin root Cookie. It hasn't been updated in 2 years, but it will fix the problem that you're having. You need the login/authentication cookie to be accessible across subdomains. Follow these directions:

  1. 安装并激活插件.
  2. 在插件设置中启用子域支持.
  3. 退出 WordPress 管理员.
  4. 再次登录并检查它是否有效.

出现此问题的原因是,当 WordPress 设置表示您已登录的 cookie 时,它​​会为管理域设置它.这意味着,当您从非管理域访问时,出于浏览器安全的考虑,不允许使用 cookie 进行身份验证.此插件更改 cookie 的 URL 以允许跨子域使用,这允许您查看前端的管理栏.

The reason that this issue occurs is because when WordPress sets the cookie that says you're logged in, it sets it for the administration domain. That means, when you visit from the non-administration domain, the cookie isn't allowed to be used for authentication due to browser security. This plugin changes the URL for the cookie to allow for use across subdomains, which allows for you to see the admin bar on the front-end.

这篇关于管理栏不会出现在 WordPress 网站的前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆