• Hello,

    I created my custom search page in WordPress with “find” slug as below URL :

    here i fetched search result which have category “removalist” i am fetching result from that query string term.

    But here i want to URL like below :

    /find/removalist

    On each search, so how can i do that can you please assist me.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You would use add_rewrite_rule() so that the regexp matches the “/find/” portion and collects the subsequent term for use in the rewritten URL that passes the collected string as the ?title= query var.

    Add the necessary code to functions.php of your theme, or preferably a child theme, or some sort of site specific plugin used to contain custom code. Don’t forget to visit the permalinks settings screen after you add your code so all the rewrite rules get regenerated.

    Thread Starter amitrivedi

    (@amitrivedi)

    Hello,

    Thank you so much for reply. I tried that and it’s working but when i am trying to pass Two query string var so at that time i got only one value from that and that is only First var.
    so can you please help me for more than one query vars.

    Moderator bcworkz

    (@bcworkz)

    Perhaps you need another rewrite rule?

    // requesting two terms
    add_rewrite_rule('find/([^/]*)/([^/]*)/?','index.php?pagename=find&title[]=$matches[1]&title[]=$matches[2]','top');

    If the GET request was /find/foo/bar/, The “find” page code will find array('foo', 'bar') assigned to $_GET['title']

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Search page In wordpress’ is closed to new replies.