Wordpress 管理栏未显示在前端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21277190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:27:31  来源:igfitidea点击:

Wordpress admin bar not showing on frontend

wordpress

提问by iWizard

I've tried everything I have found but nothing helps me.

我已经尝试了我发现的一切,但没有任何帮助。

I've put

我已经放

<?php wp_head(); ?>

in header.php

在 header.php 中

and

<?php wp_footer(); ?>

I even tried:

我什至试过:

  1. Disable all plugins
  2. Default WP theme
  3. and etc.
  1. 禁用所有插件
  2. 默认 WP 主题
  3. 等等。

采纳答案by iWizard

Solution is to putshow_admin_bar(true);on top of your functions.php file.

解决办法是把show_admin_bar(true);你的functions.php文件放在上面。

EDIT fix: Put like this to show only when user is logged in:

编辑修复:像这样只在用户登录时显示:

if (is_user_logged_in()) {
    show_admin_bar(true);
}

回答by nikky

Some custom wordpress theme doesn't show the admin bar into the theme page same with the wp_head() and the wp_footer() wrote on the templates files. To resolve that problem just add the following code into your function.php or into your own plugin:

一些自定义 wordpress 主题不会将管理栏显示到主题页面中,与模板文件上写的 wp_head() 和 wp_footer() 相同。要解决该问题,只需将以下代码添加到您的 function.php 或您自己的插件中:

function admin_bar(){

  if(is_user_logged_in()){
    add_filter( 'show_admin_bar', '__return_true' , 1000 );
  }
}
add_action('init', 'admin_bar' );

Hope that help...

希望有所帮助...

回答by Mark P

If you had the bar showing previously, you might try this super-easy fix (worked for me):

如果您之前显示了该栏,您可以尝试这个超级简单的修复(对我有用):

  1. Go to your profile in WP Admin
  2. Check to see if "Show Toolbar when viewing site" is checked
  3. If not, select this and save …?that should fix it
  4. If the option IS checked, deselect it and save. Then, select it again and save.
  1. 转到您在 WP Admin 中的个人资料
  2. 检查是否选中了“查看站点时显示工具栏”
  3. 如果没有,选择这个并保存...?应该可以修复它
  4. 如果选中该选项,请取消选择并保存。然后,再次选择它并保存。

Now have another look at the frontend. I did this and it fixed whatever the issue was without messing with any of the files.

现在再看看前端。我这样做了,它解决了任何问题,而不会弄乱任何文件。

回答by Keytrap

I have managed to make it appear again by adding

我设法通过添加使其再次出现

<?php wp_footer(); ?>

in "header.php" after </header>tag.

</header>标签后的“header.php”中。

One important thing is to clear cache (check if you have cache plugin for Wordpress installed like WP Super Cache or LiteSpeed Cache..) and then CTRL + F5 to refresh page.

一件重要的事情是清除缓存(检查您是否安装了 Wordpress 的缓存插件,如 WP Super Cache 或 LiteSpeed Cache..),然后按 CTRL + F5 刷新页面。

回答by Chris Lopo

Try disable your plug-in cache or disable for logged-in users. I had similar problem using WP Fastest Cache. Just disabled chache for logged-in users and it's working.

尝试禁用您的插件缓存或为登录用户禁用。我在使用 WP Fastest Cache 时遇到了类似的问题。刚刚为登录用户禁用了 chache 并且它正在工作。

回答by Hamid Mohayeji

If nothing helped you, try to delete all cookies. It works.

如果没有任何帮助,请尝试删除所有 cookie。有用。

回答by littledynamo

I had this problem on our production site, but it was not occurring on local or staging sites. Turns out that the WordPress Address was incorrectly set with www whereas the site was always accessed without the www.

我在我们的生产站点上遇到了这个问题,但它没有发生在本地或临时站点上。事实证明,WordPress 地址设置为错误的 www,而该站点总是在没有 www 的情况下访问。

The fix:

修复:

  • Go to settings> General
  • Ensure that WordPress Addressand Site Addressboth match your site URL exactly
  • 前往settings>General
  • 确保WordPress AddressSite Address都与您的网站网址完全匹配

Posting in case anyone else has same problem.

发布以防其他人有同样的问题。

回答by Saidmamad

Shortly: Most probably you have not logged in! Long answer: This problem happens to the new WordPress learners who try to create a custom theme. They put the wp_footer()and wp_head()functions and refresh and still do not see the admin bar. And it is because they have forgot to log in to /wp-admin/

简而言之:很可能您还没有登录!长答案:这个问题发生在尝试创建自定义主题的新 WordPress 学习者身上。他们把wp_footer()wp_head()功能和刷新,仍然看不到管理栏。这是因为他们忘记了登录/wp-admin/

回答by stloc

In my case it was missing php extensions curl and intl but above all php-curl

在我的情况下,它缺少 php 扩展 curl 和 intl 但最重要的是 php-curl

回答by Christoph Weidemann

@Chen-Tsu Lin Thanks! I tried everything- i googled the whole net- nothing did work out until i found this advice- i added your code into my blackfyre theme function.php and now its working! I really appriciate it- THANK YOU!

@Chen-Tsu Lin 谢谢!我尝试了所有方法 - 我在整个网络上搜索了 - 在我找到这个建议之前没有任何效果 - 我将您的代码添加到我的 blackfyre 主题 function.php 中,现在它可以工作了!我真的很感激它-谢谢!