问题
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?
回答1:
EDIT 2:
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:
- Install and activate the plugin.
- Enable subdomain support in plugin settings.
- Logout of the WordPress admin.
- Login again and check if it works.
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.
来源:https://stackoverflow.com/questions/24708340/admin-bar-doesnt-appear-on-the-front-end-of-a-wordpress-website