• Resolved jyamamo

    (@jyamamo)


    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]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jyamamo

    (@jyamamo)

    I started thinking about the first option (modifying the search results page) and added a bit of code to the site-wide header:

    php

    function custom_no_results_message( $message ) { $message = '<h1 class="no-results">No results found</h1>'; $message .= '<div class="no-results-content">'; $message .= '<p>Sorry, but nothing matched your search terms. Please try again with some different keywords.</p>'; $message .= get_search_form( false ); $message .= '</div>'; return $message; } add_filter( 'no_results_text', 'custom_no_results_message' );

    That didn’t work either!

    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    This plugin controls the search query. It does not alter the search results page neither there any option provided to control it.

    You need to modify the search.php file in your theme to control the output.
    Also, it seems you are using Elementor on the site, then you need to modify the Elementor template.

    I would suggest to contact the theme or Elementor support for help.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Null searches / redirect’ is closed to new replies.