@tollmanz的建议可能会起作用,但为了避免您的文本超出菜单宽度,我建议
function wpse_form_in_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
\'id\' => \'wpse-form-in-admin-bar\',
\'parent\' => \'top-secondary\',
\'title\' => \'title_goes_here\',
\'meta\' => array(
\'target\' => \'_self\',
\'html\' => \'<!-- Custom HTML that goes below the item --><form><input type="text" /><input type="submit" /> </form>\',
),
)
);
}
add_action( \'admin_bar_menu\', \'wpse_form_in_admin_bar\' );