• Resolved fruitfly

    (@fruitfly)


    If you click search without having entered anything in the form (on the blog – not the admin), it automatically returns all posts as the results. Short of having the search field pre-filled with something (which is my last ditch effort idea) – how can I stop this from happening? I’d like for it to return no results if nothing was entered.

    Many apologies if this is covered elsewhere, but searching support doesn’t seem to be cooperating with me tonight. Thanks in advance for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I doubt this one has come up before, you must have searched high and low just to come up with it. I stopped picking up pennies years ago… not worth the effort. If you click search with no entry, all posts are not returned, just the page itself. This is essentially the same as no search at all.

    So how often do you think someone does what you describe? And if they are prone to such behavior, are you sure you want them reading your blog? (they’re probably just looking at the pictures anyway ??

    I concur with Beel — besides, pre-filling the textbox won’t do any good, as a user can still delete your text. If you want to ensure there’s text to search for, you could use a javascript “onsubmit()” event for the form.

    Thread Starter fruitfly

    (@fruitfly)

    Some context might help to understand why this is an issue: it’s not for my blog, but for a little venture I’ve come up with by sort of hacking bits of WP apart to make it do what I want it to. (I just think WP is hands down the most flexible app I’ve ever worked with.)

    I’m using it to maintain a directory of businesses, with expanded listings for each one, and I’ve got the site set up to bypass index.php almost completely, except for hitting search with nothing in it. (And I do want to comment that yes, I’m SURE that there are people out there who do this. I’ve worked with the public far too long to doubt this.) Since index.php shows me whole entries instead of the excerpt, this was a problem.

    While I was responding to this to answer these questions, I answered my own dilemma by realizing that was really the issue, and so now I’ve changed index.php to show the excerpt rather than the entire entry, and voila! problem solved.

    So thanks — you guys helped me get an answer by asking me why I’m crazy. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Want to stop all posts returned if search field left blank’ is closed to new replies.