Вы имеете в виду такое?
var data = { action: 'sort_product', order: order, orderby: _this.data('orderby'), term: _this.data('term') };
$.ajax({
url: "ajaxurl",
type: "post",
data: data,
success: function(data){
$("#loop").empty().html(data);
var params = new URLSearchParams(data);
for(const [key, value] of new URLSearchParams(params)) {
if(value === "") params.delete(key);
}
window.location.hash = params;
}
});