if search query is met function

I want to create a function for wordpress that display a particular banner only if certain search terms stored in array are entered into the search box.

So for example if i entered the string “yellow” I would get a banner and search results for that string because it is in the array

Read More

But if i entered the string “orange” I would only get search terms

not too sure where to start with this so any help would be much appreciated

Cheers

Daniel Wakefield
Web Designer Cheshire

Related posts

Leave a Reply

1 comment

  1. To check if a word exists within a search term, add each searched word into an array using explode(). Then use in_array() to see if that word exists.

    $words_array = explode(' ', $_GET['s']);
    if(in_array('orange', $words_array)) {
        // search contains orange
    } else { 
        // search does not contain orange
    }