WordPress.org

Ready to get started?Download WordPress

Forums

How to link to an empty search page? (3 posts)

  1. 3stripe
    Member
    Posted 6 years ago #

    I'm a bit confused.

    Is it possible to link to an empty search page?

    I'm using the nice-search plugin (http://txfx.net/code/wordpress/nice-search/), so that something like say myblog/search/the gives me a results page as you would expect.

    But loading myblog/search/ on it's own gives me a blank page from the_title downwards.

    I had the same problem before I tried the nice-search plugin so I know it's not related to that...

    Surely there is way to link to an empty search page? (I've got a /search link in my navbar, hence the question)

    Thanks!

  2. 3stripe
    Member
    Posted 6 years ago #

    I have just realised, it's not actually showing an empty page when I goto myblog/search/, it's trying to load a 404 page, which I didn't have defined in my style.

    So including a search box on my 404 page helps a good deal!

    The problem is, you are still taken to myblog/?s= if you then leave the search box blank, and hit enter.

    Is there a way to define this redirect action?

    Maybe it is actually the nice-search plugin that needs some extra code?

    function txfx_nice_search() {
        if ( is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false ) {
            wp_redirect(get_bloginfo('home') . '/search/' . str_replace(' ', '+', str_replace('%20', '+', get_query_var('s'))));
            exit();
        }
    }
  3. 3stripe
    Member
    Posted 6 years ago #

    Or, how can I modify the search form, so that it only submits if the input textarea has something in it!? Maybe that would be easier...

    (Sorry for talking to myself)

Topic Closed

This topic has been closed to new replies.

About this Topic