Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am new to WordPress and PHP, so I have this question:

I want to add a Link to the "New Post" for a Custom Post Type I implemented. But it will only let me put static links, connected to my localhost test installation.

How do I add a non-static URL right there, like a bloginfo('wpurl') that it will actually read out?

This is what I want:

 function wp_admin_bar_new_item(){
        global $wp_admin_bar;
        $wp_admin_bar->add_menu(array(
            'id'=>'wp-admin-bar-new-item',
            'title'=>__("Kunstwerk hinzufügen"),

            'href'=>//Here it I want a link to my Custom Post Type
            ));
    }

And this is what I tried that didn't work:

function wp_admin_bar_new_item(){
    global $wp_admin_bar;
    $wp_admin_bar->add_menu(array(
        'id'=>'wp-admin-bar-new-item',
        'title'=>__("Kunstwerk hinzufügen"),

        'href'=>'bloginfo("wpurl");/../../wp-admin/post-new.php?post_type=albertis-kunstwerke'
        ));
}

and this is what is working with my localhost, but I don't want it to be static.

function wp_admin_bar_new_item(){
    global $wp_admin_bar;
    $wp_admin_bar->add_menu(array(
        'id'=>'wp-admin-bar-new-item',
        'title'=>__("Kunstwerk hinzufügen"),
        'href'=>'http://localhost:8888/test/wp-admin/post-new.php?post_type=albertis-kunstwerke'
        ));
}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

try this

'href'=> admin_url("post-new.php?post_type=albertis-kunstwerke")
share|improve this answer
    
Aww thanks so much...This actually works... –  deadfishli Dec 10 '13 at 21:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.