0

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'
        ));
}
2

try this

'href'=> admin_url("post-new.php?post_type=albertis-kunstwerke")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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