Answer the question
In order to leave comments, you need to log in
How to display everything using content filtering?
I have a content filter on the page, select the area from the drop-down list and get posts with the specified area, but if we select the default value (select the area), then in theory it should give all the posts, but does not give out, how to fix it? You can catch this value with all, but I don’t know how to display all posts.
<form action="https://....ru/wp-admin/admin-ajax.php" method="POST" id="filter">
<select class="doc__select" name="vdselect" >
<option value="all">Выберите район</option>
<option value="Адмиралтейский">Адмиралтейский</option>
<option value="Василеостровский">Василеостровский</option>
</select>
<input type="hidden" name="action" value="myfilter">
</form>
jQuery(document).ready(function($) {
$('select.doc__select').change(function(){
// Узнаем выбранный район
var city = $(this).find("option:selected").val();
if (city == 'all') {
}
var filter = $('#filter');
//filter.submit();
$.ajax({
url:filter.attr('action'),
data:filter.serialize(), // form data
type:filter.attr('method'), // POST
beforeSend:function(xhr){
},
success:function(data){
$('#response').html(data); // insert data
}
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question