Add WordPress Search Box Code in 5 Minutes Flat

Have you ever been off doing a task and gotten totally side-barred by a different idea? Happens to me all the time!

Crap. What was I talking about?

Oh yeah, so I got sidetracked this morning, but I made a cool discovery and thought I’d share it with you:

I’ll show you how to add a WordPress search box to a post or page (this tutorial is specific to sites running on the Genesis Framework).

Include a search box on a page or post in your Genesis theme

My original task was to update a post I wrote last year on creating a custom 404 page with an html sitemap. There are lots ways to skin that cat, so to speak, and part of my research had me poking around the code for Bill Erickson’s Genesis 404 Page plugin.

That’s when I stumbled on it. In the latest update to his plugin, Bill included a cool search box shortcode. If you’re using Bill’s plugin, you can go ahead and use this search shortcode anywhere in your site:


Go ahead, copy it and use it!

If you’re not using the plugin, here’s the code you can add to your Genesis theme to add search shortcode support (say that 3x fast!).

Place this in your theme’s function.php file (or wherever you add customized code to your theme):


That’s it! Now you can insert [genesis-404-search] into your post or page and a search form will magically appear. Thanks Bill for writing awesome code!

Want to see it in action? Here it is!

What do you think? Have another method to add code for a WordPress search box? Maybe a way that’s not specific to the Genesis Framework? Leave a comment below and let’s discuss!

7 day free trial


  1. Ryan Sullivan says

    Great resource Carrie! Thanks for the tip!

    I never noticed the MASSIVE featured image area on your blog before. I like it!

  2. says

    Aha! Nice one. I was thinking of writing the same tutorial when I noticed Bill updated his plugin to include the shortcode for search form. But since you’ve wrote this tutorial, now I don’t have to dig the code. Feel so great being in this AWESOME #genesiswp community :)

  3. says

    Been a long time Genesis user and just found your blog a few weeks ago. Thanks for all the code info and also for the humor. Already see a bunch of stuff here I wanna read here.

  4. says

    Hey Carrie,

    I don’t know why, but it didn’t work for me until I altered line 3 to this:
    [pre]add_shortcode( ‘genesis-404-search’, array( $this, ‘search_shortcode’ ) );[/pre]

    But now that I got it working I’m going to use it on my new theme.

    Not sure if when I hit submit the code will get mangled or not….


  5. Dan B. says

    Hmmm. It doesn’t work for me.

    I had the get the plugin, as no matter what I tried I couldn’t get the functions.php code to work.

    (on the Agency Pro them, by the way)

  6. says


    You can also try this trick.

    <form method="get" id="searchform" action="/”>

    <input type="text" value="” name=”s” id=”s” />

    Select a Category
    $allcategories= get_categories();
    foreach ($allcategories as $c) {
    $option = 'cat_ID.’”‘;
    $option .= ‘>’;
    $option .= $c->name;
    $option .= ”;
    echo $option;