我目前遇到网格插件的麻烦,当你选择一个过滤器时,它只过滤已经加载的数据。我希望它过滤数据库中的所有内容。这是我到目前为止所尝试的内容:
jQuery(document).ready(function ($) {
$('.tg-filter-name').on('click',function () {
if (window.tg_ajax) {
tg_global_var.main_query.filters_onload = []
tg_global_var.main_query.active_filters = []
var el = $('div.tg-grid-holder');
var tag_id = $(this).closest('.tg-filter').data('filter').replace('.f',''),$filter = $(this),tax= $filter.closest('.tg-filter').data('taxo')
if ($(this).closest('.tg-filter').hasClass('tg-filter-active')) {
for(var x =0; x < tg_global_var.main_query.filters_onload.length; x++) {
if (tg_global_var.main_query.filters_onload[x] == tax + ':' + tag_id) tg_global_var.main_query.filters_onload.splice(x,1)
}
for(x = 0; x < tg_global_var.main_query.active_filters.length; x++) {
if (tg_global_var.main_query.active_filters[x] == tag_id) tg_global_var.main_query.active_filters.splice(x,1)
}
} else {
tg_global_var.main_query.filters_onload.push(tax + ':' + tag_id)
tg_global_var.main_query.active_filters.push(tag_id)
}
var data = {
action: 'the_grid_load_more',
grid_nonce: tg_global_var.nonce,
grid_name: el.data('name'),
grid_page: tg_global_var.main_query.page,
main_query: tg_global_var.main_query
}
$.ajax({
url: tg_global_var.url,
type: 'post',
data: data,
dataType:'json',
success: function (resp) {
el.html(resp.content)
}
})
}
} )
} )
我还尝试在我的帖子请求中向tax_query
变量添加main_query
。有人有任何解决方案吗?