How to Add a Codex Search Box to the WordPress Dashboard

Many times when working with WordPress you’ll need to search the codex for something. I found this handy little snippet from Jared Williams that makes searching the codex very convenient. It adds a box to the header of the WordPress dashboard, as pictured here. Type in your search and it opens in a new window.

Simply add this snippet to your functions.php file and the box will appear in your dashboard:

1
2
3
4
5
6
7
8
9
/**
 * ADD WP CODEX SEARCH FORM TO DASHBOARD HEADER
 */
function wp_codex_search_form() {
    echo '<form target="_blank" method="get" action="http://wordpress.org/search/do-search.php" class="alignright" style="margin: 11px 5px 0;">
        <input type="text" onblur="this.value=(this.value=='') ? 'Search the Codex' : this.value;" onfocus="this.value=(this.value=='Search the Codex') ? '' : this.value;" maxlength="150" value="Search the Codex" name="search" class="text"> <input type="submit" value="Go" class="button" />
    </form>';
}
add_filter( 'in_admin_header', 'wp_codex_search_form', 11 );

Comments (4)

Participate