Null searches / redirect
-
Hi. I’m setting up a website and I really like the WP Extended Search plugin, but there’s one thing I’d like to change.
When a search has no results it leads to a page like this: https://u1l.9f5.myftpupload.com/?s=squog&wpessid=1765. That kind of empty page, with no options, can be off-putting for users. I’d like to do either of the following:
1. Add content (links, search boxes) to this kind of page, so instead of just getting a message saying “It seems we can’t find what you’re looking for” the user can continue searching or navigate to another page.
2. Redirect the user to a page that has content (links, search boxes).
So far, I’ve been attempting to do the second of those options. I used the 404 to 301 plugin to redirect 404 searches to a custom page, but that doesn’t seem to work for null searches. I also added the following code to the site-wide header:php
add_action('template_redirect', 'custom_no_results_redirect'); function custom_no_results_redirect() { if (is_search() && !have_posts()) { $search_query = get_search_query(); if (!empty($search_query)) { wp_redirect(get_permalink(1789), 301); exit; } } }
That doesn’t work either.
Is there a way to change or redirect the results page for searches that don’t have any results?
Thank you.
The page I need help with: [log in to see the link]
- The topic ‘Null searches / redirect’ is closed to new replies.