For example, how would I go about replacing www.example.com/search/mark+twain
with www.example.com/search/mark_twain
?
The form to search looks like this:
<form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>">
<label class="visuallyhidden" for="s"><?php _e('Search for:', 'roots'); ?></label>
<input type="text" value="" name="s" id="s" placeholder="<?php _e('Search Courses/Material'); ?> ">
<input type="submit" id="searchsubmit" value="<?php echo attribute_escape(__('Search')); ?>" class="button">
</form>
I’m not quite sure how you’re using this or where exactly you’re using that query, but you could always use string replace:
str_replace('+','_',$query)
That’s the best answer I can give with this vague a question.
PHP Manual
For jquery (which wordpress makes use of) you could do something like:
$('#sear form').submit(function(){
$(this).val($(this).val().replace(' ','_'));
});
I think that’s correct. I’m not where I can try it, but it should work.