SELECT SQL_CALC_FOUND_ROWS ariz_posts.ID
FROM ariz_posts INNER JOIN ariz_postmeta ON ( ariz_posts.ID = ariz_postmeta.post_id ) INNER JOIN ariz_postmeta AS mt1 ON ( ariz_posts.ID = mt1.post_id ) INNER JOIN ariz_postmeta AS mt2 ON ( ariz_posts.ID = mt2.post_id ) JOIN ariz_icl_translations wpml_translations
ON ariz_posts.ID = wpml_translations.element_id
AND wpml_translations.element_type = CONCAT('post_', ariz_posts.post_type)
WHERE 1=1 AND (
( ariz_postmeta.meta_key = 'activity_extra_fields_0_duration_0_date_from' AND CAST(ariz_postmeta.meta_value AS DATE) BETWEEN '20220901' AND '20220930' )
OR
( ariz_postmeta.meta_key = 'activity_extra_fields_0_duration_0_specific_date' AND CAST(ariz_postmeta.meta_value AS DATE) BETWEEN '20220901' AND '20220930' )
OR
(
( mt1.meta_key = 'activity_extra_fields_0_duration_0_date_from' AND CAST(mt1.meta_value AS DATE) <= '20220901' )
AND
( mt2.meta_key = 'activity_extra_fields_0_duration_0_date_to' AND CAST(mt2.meta_value AS DATE) >= '20220901' )
)
) AND ariz_posts.post_type = 'activity' AND ((ariz_posts.post_status = 'publish')) AND ( ( ( wpml_translations.language_code = 'en' OR 0 ) AND ariz_posts.post_type IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','um_form','arizblock','arizlist_item','service','news','tool','activity','support','facility','acf-field-group','wpcf7_contact_form','cookielawinfo','mc4wp-form','acfe-form' ) ) OR ariz_posts.post_type NOT IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','um_form','arizblock','arizlist_item','service','news','tool','activity','support','facility','acf-field-group','wpcf7_contact_form','cookielawinfo','mc4wp-form','acfe-form' ) )
GROUP BY ariz_posts.ID
ORDER BY ariz_postmeta.meta_value+0 ASC
LIMIT 0, 36