Live Blog Search

I ripped some code outta the WordPress theme K2 (the sequel to the infamous theme Kubrick that comes bundled with WordPress) that allows you to see your search results as you type.

I’ve modified it a bit and my modifications are still a work in progress, but you can check it out in the search box to the right.

(It may take a second or two to display the results as it has to query each time you type, so be patient.)

6 thoughts on “Live Blog Search

  1. Very Cool Viperbond007! I too had considered doing just this with my blog, but due to time constraints I didn’t get around to it. How difficult was it for you to “cut and paste” it? Any pitfalls I should watch for?

  2. Gotta love when your PC locks up after typing out a small essay. <_< I also notice that you've implemented it into your blog already. 😀 However, I'll still re-type out my comment (I wrote it down on paper off my frozen screen, lol) as some of it still applies.

    lol, it’s okay, I actually used to go by ViperBond007 like 7 years back. 😉

    Anyway, it wasn’t too hard, but it was kinda pain to get it to validate while keeping auto-complete off. It had been using autocomplete="off" on the input field, but that’s not valid code. I also couldn’t just pick a random, changing string for each page load as there was no easy way to get the string to both the Javascript in the header of the page as well as the form.

    I ended up naming the search field s and then the UNIX timestamp for the current time (without seconds as it often takes more than 1 second to generate my blog) as the name of the input field. This makes it basically different each time you load a page (give or take), making auto-complete not work on it.

    I then though had to have the form post to a script that’d accept the changing input field name and then redirect to the WordPress search results page in a format that WordPress could understand.

    It sounds WAY more complicated than it really was, and I’ll share the code if you want.

    It’s still a work in progress though, especially since I didn’t realize that a new version of K2 was out. I also cannot get it to go over the contents of my sidebar. It just keeps pushing the contents down and it’s driving me nuts. lol

Comments are closed.