add_action('pre_get_posts', function (WP_Query $q) {
if ( is_admin() || !$q->is_main_query() || !is_page() ) return;
$post_id = get_queried_object_id();
$raw = get_post_meta($post_id, 'pseo_filters', true);
if (!$raw) return;
$filters = json_decode($raw, true);
if (!is_array($filters)) return;
$tax_query = ['relation' => 'AND'];
foreach ($filters as $f) {
$taxonomy = isset($f['taxonomy']) ? sanitize_key($f['taxonomy']) : '';
$terms = isset($f['terms']) ? (array) $f['terms'] : [];
$field = isset($f['field']) ? $f['field'] : 'term_id';
if (!$taxonomy || empty($terms)) continue;
if ($field === 'term_id') {
$terms = array_map('intval', $terms);
} else {
$terms = array_map('sanitize_title', $terms);
}
$tax_query[] = [
'taxonomy' => $taxonomy,
'field' => $field,
'terms' => $terms,
'operator' => 'IN',
];
}
if (count($tax_query) > 1) {
$q->set('post_type', 'product');
$q->set('posts_per_page', 12);
$q->set('tax_query', $tax_query);
}
});
Schwarz Archive | Seite 81 Von 359 | Erotikwelt.org
You've just added this product to the cart:
WordPress Cookie Plugin von Real Cookie Banner