Support » Fixing WordPress » Search Broken :(

  • Resolved justbishop

    (@justbishop)


    I’m not sure what happened, but my search just recently stopped working. I’ve read through the forums, but my problem seems different. Everyone else who has a broken search issue is saying that theirs returns a 404, but mine just returns all posts, no matter what the term searched.

    Here’s my search form from header.php, and just FYI, the seach form in the default search widget is giving me the exact same results as this code.

    I have tried deactivating all search related plugins, but nothing seems to help. Is there a common problem (with a widely known solution) that could be causing this?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter justbishop

    (@justbishop)

    Just tried deactivating all exclusively active plugins on my main site one by one, doing an unsuccessful search in between each to see if I could pinpoint a problem plugin (I run Multisite and did not include network activated plugins in this test). No luck.

    A theme issue? Could something be replacing the standard query?

    Thread Starter justbishop

    (@justbishop)

    Nothing in the theme has changed between the time when it worked and the time that it didn’t. I’m not sure on the query thing…how would I find out if that were it?

    Switch themes to Twenty Ten and test the search?

    Thread Starter justbishop

    (@justbishop)

    AHA! I got rid of 2010 a while a go, but I switched to the Buddypress default theme, and search seems to work! Now to figure out what in my child theme is causing it not to >.<;;

    ETA: Experiment successful! Details to come, as I still need a bit of help…

    I’d start by looking in functions.php and header.php. In other words, anything that might be loaded before the page is displayed.

    Thread Starter justbishop

    (@justbishop)

    OK, so this is my post query on search.php:

    http://pastebin.com/BaGf9Fjn

    Now, when I delete lines 3-16 of that, search magically works as it is supposed to again. My issue with removing those lines, though, are as follows:

    1. I REALLY need posts tagged “gallery” and “blog” to not be included in search results.

    2. I REALLY need posts in cat ID #1 to not be included in search results.

    3. I REALLY need pages to not be included in search results.

    4. I REALLY need posts with no value for the custom field key “thumbnail” to not be included in search results.

    Is the code in the pastebin that’s doing the above stuff not right? Can these things be accomplished in a way that will allow the search function to work again??

    Ah! Now the weird search results kinda make sense!

    On any other template page, that query would be fine but on a search results page, you’re dealing with a specialised query, yes? Your custom query is completely over-writing it. What about concatenating your arguments (minus the paged variable) onto the existing query instead of rewriting it?

    http://pastebin.com/w0JzFd7H

    Got to admit that I’ve not tried this myself but it should work in theory.

    Thread Starter justbishop

    (@justbishop)

    AHHH! It worked! I could kiss you right now!!

    The “paged” thing, though…do I need to re-add that somewhere, or will results of more than the set amount show up paged automatically?

    Oh cool! I love it when a hunch works out. 🙂

    In theory, the original query already holds the paged variable – which is why you shouldn’t need to redeclare it in your additional arguments. The search results should just pick up the set amount from Settings->Reading.

    Thread Starter justbishop

    (@justbishop)

    Ahhhh, gotcha 😉

    And thanks again! You really have NO idea how much that helps me out!

    No problem. Gave me another new trick for my own arsenal. 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Search Broken :(’ is closed to new replies.