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

时间:2014-08-22 06:13:40

标签: php wordpress wordpress-theming

考虑以下代码:

$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'
    ),

我需要获取WP的URL值,以便我可以在管理区域中加载此代码。

我通常使用bloginfo(' url'),但我搜索到了所有地方并且无法找到使其正常工作的正确方法,只需添加绝对网址,我不会这样做。我想。

对于使这项工作的正确代码有什么想法?

1 个答案:

答案 0 :(得分:0)

更改行

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

到此:

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