Search code examples
formssearchtumblr

Tumblr: Search returning no search results


I'm new to tumblr and am trying to implement Search in a custom theme. I have:

<form action="/search" method="get" id="search-form">
    <input type="text" name="q" class="query" value="" />
    <input type="submit" value="Search" class="submit" />
    <div class="clear"></div>
</form>

I have about a dozen posts. Whenever I search for anything in any post, Tumblr always returns no search results. I feel like I'm missing something. Am I to implement or set any configuration anywhere else in the theme? What else is needed to implement search in a user's Tumblr theme?

Thanks!


Solution

  • Here's the solution I use. Put this into the <head> of your code:

    <script type="text/javascript">
    <!--
    function handleThis(formElm)
    {
    window.location="/tagged/"+formElm.number.value+"";
    return false;
    }
    -->
    </script>
    

    And place this where you want the search box to appear:

    <form onsubmit="return handleThis(this)">
    <div class="submit"><input type="submit" value="{lang:Search}" name="Submit"/></div>
    <div class="input"><input onfocus="this.value=''" onblur="if(this.value=='') this.value='Search. Then hit enter.';" type="text" value="{lang:Search}. Then hit enter." name="number"/></div>
    </form>
    

    Use CSS to style as you wish. This will search your tags only, but unlike the regular Tumblr search it works.