Title: wp_admin_bar_search_menu
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_admin_bar_search_menu( WP_Admin_Bar $wp_admin_bar )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#wp--skip-link--target)

Adds search form.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#parameters)󠁿

 `$wp_admin_bar`[WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
required

The [WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
instance.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#source)󠁿

    ```php
    function wp_admin_bar_search_menu( $wp_admin_bar ) {
    	if ( is_admin() ) {
    		return;
    	}

    	$form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
    	$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
    	$form .= '<label for="adminbar-search" class="screen-reader-text">' .
    			/* translators: Hidden accessibility text. */
    			__( 'Search' ) .
    		'</label>';
    	$form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '" />';
    	$form .= '</form>';

    	$wp_admin_bar->add_node(
    		array(
    			'parent' => 'top-secondary',
    			'id'     => 'search',
    			'title'  => $form,
    			'meta'   => array(
    				'class'    => 'admin-bar-search',
    				'tabindex' => -1,
    			),
    		)
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/admin-bar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/admin-bar.php#L1250)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/admin-bar.php#L1250-L1275)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Admin_Bar::add_node()](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_node/)`wp-includes/class-wp-admin-bar.php` |

Adds a node to the menu.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [is_admin()](https://developer.wordpress.org/reference/functions/is_admin/)`wp-includes/load.php` |

Determines whether the current request is for an administrative interface page.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_search_menu/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.3.0](https://developer.wordpress.org/reference/since/3.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_admin_bar_search_menu%2F)
before being able to contribute a note or feedback.