Dear Team,
We are using WPML together with the Event Manager Add-on, and noted that events translated into secondary languages are not showing when using the [gd_event_listing] shortcode on secondary languages pages.
From our investigation we noted that the [gd_event_listing] shortcode uses the geodir_get_widget_listings() function located in geodirectory-functions/general_functions.php.
The geodir_get_widget_listings() function uses the following sql query to return events:
SELECT wp_posts.*, wp_geodir_gd_event_detail.*, wp_geodir_event_schedule.* FROM wp_posts INNER JOIN wp_geodir_gd_event_detail ON (wp_geodir_gd_event_detail.post_id = wp_posts.ID) JOIN wp_icl_translations icl_t ON icl_t.element_id = wp_posts.ID INNER JOIN wp_geodir_event_schedule ON (wp_geodir_event_schedule.event_id = wp_posts.ID) WHERE 1=1 AND ( wp_posts.post_status = 'publish' ) AND wp_posts.post_type = 'gd_event' AND icl_t.language_code = 'es' AND icl_t.element_type = 'post_gd_event' GROUP BY wp_posts.ID ,wp_geodir_event_schedule.event_date ORDER BY wp_geodir_gd_event_detail.is_featured ASC, wp_geodir_event_schedule.event_date asc,wp_geodir_event_schedule.event_starttime asc , wp_geodir_gd_event_detail.is_featured asc, wp_posts.post_date desc, wp_posts.post_title ASC LIMIT 0, 2
The problem in our view resides in the following join:
INNER JOIN wp_geodir_event_schedule ON (wp_geodir_event_schedule.event_id = wp_posts.ID)
Indeed wp_geodir_event_schedule only contains a line for the original event but no lines for the translated (or duplicated) events.
Therefore wp_geodir_event_schedule.event_id cannot correspond to any translated wp_posts.ID .
The above query can therefore only return empty results when used with secondary languages.
Of course the gd_event CPT is set to ‘translatable’ in WPML settings just like our other CPTs.
Is there any fix to the above?
Many thanks and best regards,