Thread Starter
jewbi
(@jewbi)
hi thanks for the replie 🙂
I tried this topic and unfortunatly it didnt work for me.
Try adding this to your themes functions.php file
function search_url_rewrite_rule() {
if ( is_search() && !empty($_GET['s'])) {
wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redirect', 'search_url_rewrite_rule');
Note the /search/ section is what you will be renaming your search url too
As seen here: http://bavotasan.com/2011/rewrite-search-result-url-for-wordpress/
Thread Starter
jewbi
(@jewbi)
ok so if I understand correctly, I have to add this code to function.php and change my .htaccess with this line : RewriteRule ^search/(.+)$ index.php?s=$1&search=true [L]
Is that correct?
I would not worry about the htaccess file for now unless the above does not work. Just make that edit by adding the above code to the bottom of your themes functions.php file and you should be all set.
*Note if there is a closing ?> tag at the bottom of your functions file then the above code will need to go ABOVE that. If it doesnt have one then just add the above code to the bottom of the functions file.
Thread Starter
jewbi
(@jewbi)
I try the code in my function.php and when I’m trying to search, it redirect to home page without doing any search
Hmm, I just confirmed that this does work.
Can you provide a link to your website and use something like pastebin.com to paste the code from your functions.php file?
Thread Starter
jewbi
(@jewbi)
For sure. Thank you very much for the help
Here it is : http://pastebin.com/GHVTpSBn
website: http://accrosauxencheres.com/
the password to acces the site is : password
That is weird, Checked on a few different installs and themes and it worked perfectly.
Does your theme have a search.php page?
Thread Starter
jewbi
(@jewbi)
yes i have. Could it be a conflict with a plugin? I’m currently using buddypress and ultimate action pro
I mean you can try it just for assurance. try deactivating those plugins then check.
Otherwise this is just a custom theme built of twenty-thirteen is that right?
Thread Starter
jewbi
(@jewbi)
yep it’s right. I just made a copy of the theme and change what I need to change.
Ok, check the plugins to see if that would be causing an issue and I dont know if this will work but sometimes helps – try changing the permalinks back to default and check again, then change them back to how you had it and do a double check.
Let me know if any of this helps
Thread Starter
jewbi
(@jewbi)
You are amazing! It finally work. Thank you sooooo much
😉 Glad you got it working, lovely site by the way!