Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #357345

    Hi!

    I was looking how to change the default
    /?s=

    I found out this code, but I didn’t work, I also found a .htaccess code, but I didn’t made any change either

    function change_search_url_rewrite() {
        if ( is_search() && ! empty( $_GET['s'] ) ) {
            wp_redirect( home_url( "/buscar/" ) . urlencode( get_query_var( 's' ) ) );
            exit();
        }   
    }
    add_action( 'template_redirect', 'change_search_url_rewrite' );

    Any suggestions?

    Thank you!

    #357954

    Hi C-LabMX!

    Your code is working fine on my end. Make sure to add it to the bottom of the functions.php file. You may also need to refresh your permalinks in Dashboard > Settings > Permalinks and set it to post name. Make sure to deactivate all plugins while testing.

    This is more of a general WordPress question than the theme so it would be best to ask in the WordPress support forums, https://wordpress.org/support/.

    Best regards,
    Elliott

    #363815

    Hi Ellliott!
    Thanks for your response, the only URL that is pending is the main one /?s= when I search something it do changes to the new one. But well, I’ll check in WordPress Forum, I saw a topic in here with a similar question, that’s why I asked, good to now.
    Thanks again!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Personalized search url’ is closed to new replies.