Ask your WordPress questions! Pay money and get answers fast! (more info)

Define page for search results WordPress


Hello, is there a way (or plugin ideally) to define certain pages to land on when a search is made.

For example if someone searches 'cakes', I would like for the 'cakes' page to be shown rather than a list of search results which include the keyword 'cakes'

I've heard this is possible, but need some guidance.

Answers (3)


Navjot Singh answers:

You can use this plugin - [[LINK href=""]]Search Keyword Redirect[[/LINK]]


Galia Bahat answers:

UX wise I wouldn't do that - when a user does a search they expect a search results page. If the wevsite doesn't begave as they expect they might perceive that as an error.
(Instinctively, before they even think about it)

And what if I was looking for a brand of waffles called "vakes", typo'd "cakes" and didn't notice... I'd get to the wrong page and possibly have no idea why the website did that.

I'd use autocomplete if I were you, does the job (you type "ca...", choose "cakes" from the list, get the cakes page) and I'm sure there are giod plugins for it because it's quite common.

Galia Bahat comments:

Website* behave* I'm typing on a phone, sorry :-)


Arnav Joy answers:

the following code is not a solution but you can try it ..

if search result only gives you one result and that is title of the page then it redirects you to that page

add_action('template_redirect', 'redirect_to_page');
function redirect_to_page() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );