Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search url. #56

Open
StevenDufresne opened this issue Nov 23, 2022 · 3 comments
Open

Improve search url. #56

StevenDufresne opened this issue Nov 23, 2022 · 3 comments
Labels
[Component] Backend Anything wp-admin or PHP-related
Milestone

Comments

@StevenDufresne
Copy link
Collaborator

Copied from pattern directory.

function rewrite_urls() {
	// Redirect searches to `/search/term`.
	if ( is_search() && ! empty( $_GET['s'] ) ) {
		wp_redirect( home_url( '/search/' ) . urlencode( trim( get_query_var( 's' ) ) ) . '/' );
		exit();
	}
}

@StevenDufresne StevenDufresne added this to the Future milestone Dec 5, 2022
@ryelle ryelle added the [Component] Backend Anything wp-admin or PHP-related label Aug 1, 2023
@ryelle
Copy link
Contributor

ryelle commented Aug 1, 2023

This was necessary in the pattern directory because of the routing & SPA, I think. Is there a reason we need it for the showcase? SEO, maybe?

@StevenDufresne
Copy link
Collaborator Author

I can't remember exactly but the main site uses that pattern. We should probably maintain the consistency. I don't feel strongly though.

@ryelle
Copy link
Contributor

ryelle commented Aug 1, 2023

I think that's also because the search page on that site needs to be the Search page for the google embed. In any case, consistency is good and I'm fine with establishing this as the way things should work.

The permalink https://wordpress.org/showcase-v2/search/vogue/ already works as a route, the issue here is redirecting /showcase/?s=term to /showcase/search/term/ — which is what the code above does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Backend Anything wp-admin or PHP-related
Projects
None yet
Development

No branches or pull requests

3 participants
@ryelle @StevenDufresne and others