WordPress admin bar 添加自定义链接菜单
要在WordPress的admin bar中添加自定义链接菜单,您可以在主题的functions.php文件中添加代码。以下是一个示例代码,演示如何添加自定义链接菜单:
function custom_toolbar_link($wp_admin_bar) {
$plugin_manage = array(
'id' => 'custom_link',
'title' => 'imwpweb', // 名称
'href' => 'https://www.imwpweb.com',// 链接
);
$wp_admin_bar->add_node($plugin_manage);
}
add_action('admin_bar_menu', 'custom_toolbar_link', 999);
在上述代码中,add_action('admin_bar_menu', 'custom_toolbar_link', 999);
表示在admin bar菜单中添加一个名为custom_toolbar_link
的函数,该函数的优先级为999。
然后,在custom_toolbar_link
函数中,我们使用$wp_admin_bar->add_node()
方法添加一个新的菜单项。在这个示例中,我们添加了一个顶级菜单项,其ID为custom_link
,标题为“自定义链接”,链接为 https://www.imwpweb.com。
你可能还喜欢下面这些文章
最近发现 有不少文章配上图片,写得比较长。’wp_more’,<if ( strpos( $content,'<if ( strpos( $content, ‘<
php the_content();$content = $post->//limit content if (count($content)>
wordpress实现自定义短代码。// @param $content 短代码里面的内容// @param $code 短代码function hello($atts, $content=null, $code=””) {
WordPress文本小工具中可以添加任意HTML代码,但默认PHP代码添加到文本小工具中却不能运行,下面的这段代码很有用! $text = ob_get_contents();
我熟悉 WordPress 并使用 WordPress 菜单系统。在您的functions.php创建一个类,使用与父类非常相似的方法来扩展Walker_Nav_Menu :
wp_register_script( ‘some_handle’, ‘< wp_localize_script( ‘translations’, ‘DialogMessages’, [ ‘Are you sure you wan
从wordpress后台登入自己的博客网站。仪表盘中找到页面——新建页面。填写页面名称——修改固定链接——在文本情况下输入以下代码:【代码如图中所示】简单便捷好用【图中为演示地址】
让WordPress一个页面显示全部分类的文章cat=’ . $cat->php echo $cat->a href=”<$cats = get_categories(array(‘include’ =>