Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom Thesis Search Box in WP Admin bar WordPress


I'm using the Thesis theme and wp 3.3 and i'd like to remove the default wp admin bar search (on the far right of the bar in wp3.3), and then replace this with the Thesis search box which i'm using elsewhere in my theme.

The code i have for the Thesis search box is:
<?php thesis_search_form(); ?>

And I need to add custom style to this search box too which i'm doing elsewhere using a list class:

<li class="search_top_nav"><?php thesis_search_form(); ?></li>

I also need to be able to position this search box anywhere on the admin bar, not just back on the far right like the standard search.

Answers (3)


Manoj Raj answers:

Here is the code to remove the default search form from wp admin bar and add a new menu

function my_admin_bar_menu() {
global $wp_admin_bar;

if ( !is_super_admin() || !is_admin_bar_showing() )

//Remove search option from admin bar


// Add a new menu item

$wp_admin_bar->add_menu( array(
'id' => 'newlink',
'title' => __( 'WP Experts'),
'href' => FALSE ) );

add_action('admin_bar_menu', 'my_admin_bar_menu');

Here is the code from WP-admin-bar.php for search form.. In this way you can add your own form...

* Add search form.
* @since 3.3.0
function wp_admin_bar_search_menu( $wp_admin_bar ) {
if ( is_admin() )

$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" tabindex="10" type="text" value="" maxlength="150" />';
$form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';
$form .= '</form>';

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

robster comments:

Thanks Manoj - managed to use the remove search function you posted and modified the existing search function you also posted to insert this pretty much how I needed!


nina magbanua answers:

where do you want to position your search box on the admin? can you give me an access to your admin so I can check it?

robster comments:

On a development server so can't provide access i'm afraid.

Ideal position is near the right of the bar, and to the left of the profile link.

nina magbanua comments:

can you provide images? so i can see what you mean.

robster comments:


I have added an image of where I would like the search box to be.

As long as the search has a class/id I can style this.