+ therebel Posted October 12, 2018 Report Share Posted October 12, 2018 This short tutorial will cover the following search slug transformation: mydomain.com/?s=search-term to mydomain.com/search/search-term Two methods I know: 1st method: Editing Your Theme Functions File by adding at the end of the file /** * Change search page slug to /search/ */ function wp_change_search_url() { if ( is_search() && ! empty( $_GET['s'] ) ) { wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) ); exit(); } } add_action( 'template_redirect', 'wp_change_search_url' ); 2nd method: Using .htaccess (apache) # Change WordPress search URL slug to /search/ RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC] RewriteRule ^$ /search/%1/? [NC,R,L] Both methods presume you want to use /search/ , but you can change it to whatever you want. Enjoy! Link to comment Share on other sites More sharing options...
+ Arlin360 Posted October 13, 2018 Report Share Posted October 13, 2018 (edited) Gran aporte a la comunidad, Sólo algo que noté Haciéndolo a través de functions. Si se escribe el nombre de una pelicula con varias por ejemplo "Batman" Si seleccionas "Ver todos los resultados", siempre te redirecciona al primer resultado de la opciones. A través de .htaccess sucede lo mismo, pero solo si pongo otra palabra que sea diferente a "search" Saludos. Edited October 13, 2018 by Arlin360 Link to comment Share on other sites More sharing options...
+ therebel Posted October 14, 2018 Author Report Share Posted October 14, 2018 On 10/13/2018 at 2:01 PM, Arlin360 said: Great contribution to the community, Only something that I noticed Doing it through functions. If you write the name of a movie with several for example "Batman" If you select "See all results", it always redirects you to the first result of the options. Through .htaccess the same thing happens, but only if I put another word that is different from "search" Greetings. Hi, I didnt get your comment, anyway, i did it through functions, and the results comes out as they should with the domain/search/batman https://picr.ws/d/ZQ0.jpg cheers. Link to comment Share on other sites More sharing options...
+ Babaman Posted November 29, 2019 Report Share Posted November 29, 2019 Thanks for this, so the search results are also cached Link to comment Share on other sites More sharing options...
+ DYG989 Posted March 25, 2021 Report Share Posted March 25, 2021 Thank you very much. Link to comment Share on other sites More sharing options...
Recommended Posts