-
-
Save pavlo-bondarchuk/9d648062a114de91ff502432c460e273 to your computer and use it in GitHub Desktop.
sort&filter wp_query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--//--> | |
<?php | |
$order = "&orderby=date&order=DESC"; | |
$s2 = ' selected="selected"'; | |
if ($_POST['select'] == 'title') { $order = "&orderby=title&order=ASC"; $s1 = ' selected="selected"'; $s2 = ''; } | |
if ($_POST['select'] == 'newest') { $order = "&orderby=date&order=DESC"; $s2 = ' selected="selected"'; } | |
if ($_POST['select'] == 'oldest') { $order = "&orderby=date&order=ASC"; $s3 = ' selected="selected"'; $s2 = ''; } | |
if ($_POST['select'] == '2016') { $order = "&year=2016"; $s4 = ' selected="selected"'; $s2 = ''; } | |
if ($_POST['select'] == '4') { $order = "&posts_per_page=4"; $s4 = ' selected="selected"'; $s2 = ''; } | |
if ($_POST['select'] == '6') { $order = "&posts_per_page=6"; $s5 = ' selected="selected"'; $s2 = ''; } | |
?> | |
<form class="form-submit" method="post" id="order"> | |
Сортировать по: | |
<select name="select" onchange='this.form.submit()'> | |
<option value="title"<?=$s1?>>по заголовку</option> | |
<option value="newest"<?=$s2?>>по дате (сначала новые)</option> | |
<option value="oldest"<?=$s3?>>по дате (сначала старые)</option> | |
<option value="4"<?=$s4?>>4 поста</option> | |
<option value="6"<?=$s5?>>6 поста</option> | |
</select> | |
</form> | |
<?php query_posts($order); ?> | |
<!--//--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment