// קוד להצגת רשומות רק מקטגוריה מסוימת
function custom_listing_query() {
// בדיקה אם אנו בדף רשומת CPT של מכוניות
if (is_singular('cars')) {
// קבלת קטגוריה של המכונית הנוכחית
$terms = get_the_terms(get_the_ID(), 'car_brands');
if ($terms && !is_wp_error($terms)) {
$brand_slugs = array();
foreach ($terms as $term) {
$brand_slugs[] = $term->slug;
}
// יצירת Query לרשומות עם אותה קטגוריה
$args = array(
'post_type' => 'cars',
'tax_query' => array(
array(
'taxonomy' => 'car_brands',
'field' => 'slug',
'terms' => $brand_slugs,
),
),
);
$custom_query = new WP_Query($args);
// קוד להצגת הרשומות בליסטינג
if ($custom_query->have_posts()) :
while ($custom_query->have_posts()) : $custom_query->the_post();
// הצגת רשומה
the_title();
endwhile;
wp_reset_postdata();
else :
echo 'לא נמצאו רשומות.';
endif;
}
}
}
add_action('elementor/query/{$your_query_id}', 'custom_listing_query');