1

I'm trying to figure out how to add an item to the new menu bar. To be clear, I know how to add items to the menu bar. I want to add something new under the bug plus sign in the admin bar. Here's a pic of the admin bar I'm looking to add an item to.

Pic of what I want to do

The code from my plugin looks like this.

        $args = array(
        'id'     => 'test1234',     // id of the existing child node (New > Post)
        'title'  => 'test', // alter the title of existing node
        'parent' => 'new-link',          // set parent to false to make it a top level (parent) node
        'href'  => admin_url('admin.php?page=enter_timesheet')
    );
    $wp_admin_bar->add_node( $args );

I'm assuming I just need to modify the 'parent' tag to something, but I'm not sure what. I've found this to be shockingly poorly documented (or my Bingle-foo is failing me).

1 Answer 1

0

Use new-content :

function make_parent_node($wp_admin_bar) {
    $args = array(
        'id' => 'test1234', // id of the existing child node (New > Post)
        'title' => 'test', // alter the title of existing node
        'parent' => 'new-content', // set parent to false to make it a top level (parent) node
        'href' => admin_url('admin.php?page=enter_timesheet')
    );
    $wp_admin_bar->add_node($args);
}

it will show at the bottom:

enter image description here

you can see the ID of the parent node in the HTML if you dont want to dig in the core files:

enter image description here

they will be like wp-admin-bar-{ID-name}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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