Created
June 28, 2024 12:44
-
-
Save kartikparmar/8df171d8e9f42f0e878eef1dfefdf789 to your computer and use it in GitHub Desktop.
Fetch bookings for given product id and available comment data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'bkap_booking', // Replace with your actual custom post type | |
'meta_query' => array( | |
'relation' => 'AND', | |
array( | |
'key' => '_bkap_product_id', | |
'value' => '123', | |
'compare' => '=' | |
), | |
array( | |
'key' => '_bkap_additional_comment', | |
'value' => '', | |
'compare' => '!=' | |
) | |
) | |
); | |
$query = new WP_Query($args); | |
if ($query->have_posts()) { | |
while ($query->have_posts()) { | |
$query->the_post(); | |
// Your code to display or process the booking data | |
$booking_id = get_the_ID(); | |
$product_id = get_post_meta($booking_id, '_bkap_product_id', true); | |
$additional_comment = get_post_meta($booking_id, '_bkap_additional_comment', true); | |
echo 'Booking ID: ' . $booking_id . '<br>'; | |
echo 'Product ID: ' . $product_id . '<br>'; | |
echo 'Additional Comment: ' . $additional_comment . '<br>'; | |
} | |
wp_reset_postdata(); | |
} else { | |
echo 'No bookings found.'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment