简体   繁体   中英

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.

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.

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/') )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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