SELECT wp_posts.*, 1 rooms_available, 0 rooms_booked , IFNULL((SELECT price_meta2.meta_value + 0 FROM wp_postmeta price_meta2 WHERE price_meta2.post_id=wp_posts.ID AND price_meta2.meta_key='_accommodation_min_price:2024-10-07:2026-10-07' LIMIT 1), 0) accommodation_price
FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) JOIN wp_icl_translations wpml_translations
ON wp_posts.ID = wpml_translations.element_id
AND wpml_translations.element_type = CONCAT('post_', wp_posts.post_type) LEFT JOIN wp_icl_translations wpml_translations_default ON wpml_translations_default.trid = wpml_translations.trid AND (wpml_translations_default.source_language_code IS NULL OR wpml_translations.source_language_code IS NULL)
WHERE 1=1 AND (
( wp_postmeta.meta_key = 'accommodation_location_post_id' AND wp_postmeta.meta_value IN ('2276') )
) AND wp_posts.post_type = 'accommodation' AND ((wp_posts.post_status = 'publish')) AND ( ( ( wpml_translations.language_code = 'en' OR (
wpml_translations.language_code = 'en'
AND wp_posts.post_type IN ( 'customize_changeset','e-landing-page','elementor_library','extra_item','room_type' )
AND ( (
( SELECT COUNT(element_id)
FROM wp_icl_translations
WHERE trid = wpml_translations.trid
AND language_code = 'en'
) = 0
) OR (
( SELECT COUNT(element_id)
FROM wp_icl_translations t2
JOIN wp_posts p ON p.id = t2.element_id
WHERE t2.trid = wpml_translations.trid
AND t2.language_code = 'en'
AND (
p.post_status = 'publish' OR p.post_status = 'private' OR
( p.post_type='attachment' AND p.post_status = 'inherit' )
)
) = 0 ) )
) ) AND wp_posts.post_type IN ('post','page','attachment','customize_changeset','wp_block','wp_template','wp_template_part','wp_navigation','e-landing-page','elementor_library','location','extra_item','room_type','accommodation','acf-field-group' ) ) OR wp_posts.post_type NOT IN ('post','page','attachment','customize_changeset','wp_block','wp_template','wp_template_part','wp_navigation','e-landing-page','elementor_library','location','extra_item','room_type','accommodation','acf-field-group' ) )
GROUP BY wp_posts.ID HAVING 1=1
ORDER BY wp_posts.post_title ASC