Answer the question
In order to leave comments, you need to log in
How to hide the end of a link in the address bar?
Good day everyone!
There is a post filter made in php in wordpress:
<?php
if ($_GET['select'] == 'a1') { $order = "&orderby=views&order=DESC"; $s1 = ' selected="selected"'; }
if ($_GET['select'] == 'a2') { $order = "&orderby=date&order=DESC"; $s2 = ' selected="selected"'; }
?>
<form method="get" id="order">
<select name="select" onchange='this.form.submit()' class="sort">
<option value="a1"<?=$s1?>>По популярности</option>
<option value="a2"<?=$s2?>>По дате</option>
</select>
</form>
<?php global $query_string;
query_posts($query_string.'&'.$order);
?>
?select=a1
Answer the question
In order to leave comments, you need to log in
Change in the get form to post.
Well, respectively, in checking $_GET for $_POST.
You probably do not need to hide the end of the address bar, but throw out the already unnecessary select parameter?
Something like that, if query_string is really query_string, and not something else
$query=[];
parse_str(parse_url($query_string, PHP_URL_QUERY),$query_array);
unset($query_array['select']);
echo (!empty($query_array)?'?':'').http_build_query($query_array);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question