Hey friends we are almost at the end of the creation of the blog pages and today we'll create a search
template.
At the moment our search is working as follows.
If commerce is active in the user's installation the search returns only products as results.
Otherwise it works as a standard WordPress search showing posts and pages.
Among the results that will ensure that our theme will work even if the user doesn't have commerce activated.
However what happens when we do a search without McComas activated.
Let's see.
Well what happened is that the template file being used is to index that BGP so to avoid this we can
create a new file called search that BHP.
We can make the search look even a little different if you want to.
Let's see how to do that today I'll start by creating a file called Search dot BHP of course
and they'll make a copy of the next dot BGP.
Let's go ahead and modify the documentation.
Now let's do some pretty basic search here so notice here that the template files and how to search
that page be really cool.
Well we can improve our results page a bit more.
One of the things WordPress recommends for field developers is that the results page also has search
form.
So if the users want to do the search again using another term they can do it faster to do this before
our loop starts.
Let's call up the search form again.
But that's pretty easy.
We just need to call the get search form function again.
By doing this we'll have the form at the top of the page again.
We're going to need a little success later to make this look better.
K.
Another thing we can do is to type before the second form something that shows more clearly which term
is being searched for
we can for example do this site in H1 tag search results for to repeat the search term.
Let's use the get search query function less passive.
Here again
however we have to do an echo here.
Okay.
Remember this is the function that starts with get.
So it only returns something we have to equate out to see the results on the screen.
Let's say that and now refreshing the search page.
We get the search term here.
Very nice indeed
let's change a little bit.
This message below.
If there is no result we want to show another message.
For example there are no results for your query
perfect all set.
Now we can activate all commerce again.
And that's it.
Thanks for your attention guys.
See you next time.
Until then.