我希望在我的WP管理栏子菜单中以文本形式回应当前主题。
如何在\'title\' => \'php snippet here\',
?
http://codex.wordpress.org/Function_Reference/get_current_themehttp://codex.wordpress.org/Function_Reference/add_menu
$theme_name = get_current_theme();
echo $theme_name;
我希望在我的WP管理栏子菜单中以文本形式回应当前主题。
如何在\'title\' => \'php snippet here\',
?
http://codex.wordpress.org/Function_Reference/get_current_themehttp://codex.wordpress.org/Function_Reference/add_menu
$theme_name = get_current_theme();
echo $theme_name;
第一件事get_current_theme()
从您需要使用的版本3.4开始,已弃用wp get theme()
获取当前主题名称。
关于add_menu() 你只能在动作钩上使用admin_bar_menu
像codex 说说看:
这不是一个函数。它是$wp\\u admin\\u bar global(wp\\u admin\\u bar的一个实例)的一种方法,它可能不存在,除非在“admin\\u bar\\u menu”挂钩期间。
工作示例
function foo_test_menu() {
global $wp_admin_bar;
$current_theme = wp_get_theme();
$wp_admin_bar->add_menu( array(
\'id\' => \'your_menu_id\',
\'title\' => $current_theme->get(\'Name\')
) );
}
add_action(\'admin_bar_menu\', \'foo_test_menu\');
我正在尝试将WordPress升级到最新的4.2.2版本。在屏幕上,我看到: Downloading update from https://downloads.wordpress.org/release/wordpress-4.2.2-no-content.zip… Unpacking the update… Could not create directory. Installation Failed 在php错误日志中 PHP Fatal error