SELECT wp_posts.*
FROM wp_posts 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)
WHERE 1=1 AND wp_posts.post_type = 'promotion' AND ((wp_posts.post_status = 'publish')) AND ( ( ( wpml_translations.language_code = 'en' OR (
wpml_translations.language_code = 'en'
AND wp_posts.post_type IN ( 'vcv_headers','vcv_footers','vcv_sidebars','vcv_layouts','vcv_templates','vcv_popups' )
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','wp_block','wp_template','wp_template_part','wp_navigation','facility','home-banner','home-hero-banner','storage-size','packing-supply','faq','selfstorageinsurance','storage-tip','system','personal-storages','promotion','facility-vt','testimonial','content_block','vcv_headers','vcv_footers','vcv_sidebars','vcv_layouts','vcv_templates','vcv_popups' ) ) OR wp_posts.post_type NOT IN ('post','page','attachment','wp_block','wp_template','wp_template_part','wp_navigation','facility','home-banner','home-hero-banner','storage-size','packing-supply','faq','selfstorageinsurance','storage-tip','system','personal-storages','promotion','facility-vt','testimonial','content_block','vcv_headers','vcv_footers','vcv_sidebars','vcv_layouts','vcv_templates','vcv_popups' ) )
ORDER BY wp_posts.post_date ASC