Search Permalink: replace string "?s=" to permalink structure (4 posts)

  1. webbando
    Posted 2 years ago #


    is it possible to change the normal string ?s= to a permalink structure?

    In particular I need to have the following url:


    instead of:

    So, I need to delete "?s=" and replate the "+" with the "-".

    Is it possible?

  2. bcworkz
    Posted 2 years ago #

    Yes! You will mainly be using add_rewrite_rule(). This basically accepts a permalink like you envision and rewrites it back the way it is normally behind the scenes so the request parser knows that it's a search request.

    You'll also need to use the 'request' filter to convert the hyphens back to pluses.

  3. webbando
    Posted 2 years ago #

    Hi bcworkz.. Thanks a lot for your reply.

    Do you already have the code (php and htaccess) that I need?

    Thanks a lot again for your time.

  4. bcworkz
    Posted 2 years ago #

    Sorry, no. Truth be told, I haven't fully figured out rewrites. Sometimes they work fine, other times not. I haven't figured out an efficient debug method to determine why things don't work either. I can suggest you ensure your regexp is working independent of rewrites before attempting to use it in rewrites.

    Also that when using the WP Rewrite API, you don't need to be concerned about .htaccess, WP will revise its entry if it needs to. It's also possible to use a solely .htacces solution independent of the WP Rewrite API. Hopefully yours is one of those implementations that work fine right away. Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.