Wordpress Debug Log
[22-Jul-2024 15:50:22 UTC] bricks/terms/query_vars filter called for element ID: vaonjt
[22-Jul-2024 15:50:22 UTC] Post IDs retrieved: 11962,11943,8815,7337,7313,7302,9036,9035,6524,8921,6498,9016,6481,6445,6464,6462,6301,6447,6438,6440,6434,6427,6425,6412,6402,6396,6371,6361,6352,6345,6336,6341,6339,6331,6329,6322,6319,6313,6312,6310,6297,6295,6288,6279,6264,6256,6254,6251,8924,6237,6202,6179,5832
[22-Jul-2024 15:50:22 UTC] Modified query vars: Array
(
[taxonomy] => Array
(
[0] => industry
)
[orderby] => count
[order] => desc
[number] => 25
[paged] => 1
[original_offset] => 0
[object_ids] => Array
(
[0] => 11962
[1] => 11943
[2] => 8815
[3] => 7337
[4] => 7313
[5] => 7302
[6] => 9036
[7] => 9035
[8] => 6524
[9] => 8921
[10] => 6498
[11] => 9016
[12] => 6481
[13] => 6445
[14] => 6464
[15] => 6462
[16] => 6301
[17] => 6447
[18] => 6438
[19] => 6440
[20] => 6434
[21] => 6427
[22] => 6425
[23] => 6412
[24] => 6402
[25] => 6396
[26] => 6371
[27] => 6361
[28] => 6352
[29] => 6345
[30] => 6336
[31] => 6341
[32] => 6339
[33] => 6331
[34] => 6329
[35] => 6322
[36] => 6319
[37] => 6313
[38] => 6312
[39] => 6310
[40] => 6297
[41] => 6295
[42] => 6288
[43] => 6279
[44] => 6264
[45] => 6256
[46] => 6254
[47] => 6251
[48] => 8924
[49] => 6237
[50] => 6202
[51] => 6179
[52] => 5832
)
)
<?php
add_filter('bricks/terms/query_vars', function($query_vars, $settings, $element_id) {
// Debugging: Log the function execution
error_log('bricks/terms/query_vars filter called for element ID: ' . $element_id);
if ($element_id !== 'vaonjt') {
error_log('Element ID does not match. Returning original query vars.');
return $query_vars;
}
// Perform a custom WP_Query to get posts with the required meta key and value
$args = [
'post_type' => 'jobs',
'meta_query' => [
[
'key' => 'job_oeffentlich',
'value' => 'public',
'compare' => '=',
],
],
'fields' => 'ids', // Only get post IDs
'posts_per_page' => -1,
];
$query = new WP_Query($args);
$post_ids = $query->posts;
// Debugging: Log the post IDs retrieved
error_log('Post IDs retrieved: ' . implode(',', $post_ids));
// Use the post IDs to filter the terms
$query_vars['object_ids'] = $post_ids;
// Debugging: Log the modified query vars
error_log('Modified query vars: ' . print_r($query_vars, true));
return $query_vars;
}, 10, 3);