WordPress.org

Support

Support » Plugins and Hacks » Nice Search » [Plugin: Nice Search] Added Missing Pagination(Have a similar Plugin)

[Plugin: Nice Search] Added Missing Pagination(Have a similar Plugin)

  • Added pagination, and a PERM redirect to avoid SEO problems.
    Also removed the “+” from URL too.

    function cws_nice_search_redirect() {
    
    	if ( is_search() && strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) === false && strpos( $_SERVER['REQUEST_URI'], '/search/' ) === false ) {
    
    		$clean = str_replace( array( '+',' ', '%20' ),  array( '-', '-', '-' ), get_query_var( 's' ) );
    		if(strpos( $_SERVER['REQUEST_URI'], '/page/' ) === false)
    		{
    			wp_redirect( home_url( '/search/' . $clean ), 301 );
    			exit();
    		}
    		else
    		{
    			wp_redirect( home_url( '/search/' . $clean ."/page/" . get_query_var( 'paged' ) ), 301 );
    			exit();
    		}
    	}
    }

    Thanks, nice job.

  • The topic ‘[Plugin: Nice Search] Added Missing Pagination(Have a similar Plugin)’ is closed to new replies.
Skip to toolbar