如何在wordpress管理侧边栏上添加自定义链接 [英] how to add custom link on wordpress admin sidebar
本文介绍了如何在wordpress管理侧边栏上添加自定义链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用插件的情况下在 wordpress 管理侧边栏上添加自定义链接?例如,我想添加Google.com"链接.我该怎么做?
How to add custom link on wordpress admin sidebar without using plugins? For example, i want to add "Google.com" link. How should i do this?
我试过这个:将下一个代码添加到 admin-bar.php
I tried this: Added next code to admin-bar.php
function mycustomlink() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'parent' => 'new-content',
'id' => 'mycustomlinkId',
'title' => __('Custom link'),
'href' => admin_url( 'google.com'),
'meta' => false
));}
并将下一个代码添加到 class-wp-admin-bar.php
And added next code to class-wp-admin-bar.php
add_action( 'admin_bar_menu', 'mycustomlink', 900 );
但没有结果.
推荐答案
将此添加到主题的 function.php 底部
Add this to the bottom of your theme's function.php
add_action( 'admin_menu', 'linked_url' );
function linked_url() {
add_menu_page( 'linked_url', 'External link', 'read', 'my_slug', '', 'dashicons-text', 1 );
}
add_action( 'admin_menu' , 'linkedurl_function' );
function linkedurl_function() {
global $menu;
$menu[1][2] = "http://www.example.com";
}
这篇关于如何在wordpress管理侧边栏上添加自定义链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文