简体   繁体   English

如何在PHP函数中加载bloginfo URL?

[英]How do I load bloginfo URL in PHP function?

Consider this code: 考虑以下代码:

$admin_bar->add_menu( array(
    'id'    => 'options_page',
    'parent' => 'customize_page',
    'title' => 'Options Page',
    'href' => admin_url( 'customize.php?url=/my_page/'),
    'meta'  => array(
        'title' => __('Options Page'),
        'target' => '_self',
        'class' => 'my_menu_item_class'
    ),

I need to get the value of WP's URL so that I can load this code in the admin area. 我需要获取WP URL的值,以便可以将此代码加载到管理区域中。

I usually use bloginfo('url'), but I searched everywhere and couldn't find the proper way to make it work, only by adding the absolute URL, which I don't want to. 我通常使用bloginfo('url'),但是我到处搜索并且找不到合适的方法,只能添加绝对不需要的绝对URL。

Any idea on what's the correct code to make this work? 关于使该工作正确的代码是什么的任何想法?

Change the line 换线

admin_url( 'customize.php?url=/my_page/')

to this: 对此:

admin_url( 'customize.php?url='. site_url('/my_page/') )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM