Waiting for author
Overview of the issue
When translating events created with WP Event Manager and WPML, Organizer and Venue fields do not always display in the default language on the front-end.
Workaround
Please be sure to have a full backup of your site before proceeding.
You will need to make the following changes.
- Go to WPML → Settings → Custom fields translation
- Set the _event_organizer_ids and _event_venue_ids custom fields to Copy.
- Then, open the /wp-content/plugins/wp-event-manager/wp-event-manager-template.php file.
- Look for line 1229.
- Change:
foreach ($post->_event_organizer_ids as $key => $organizer_id) {
To:
foreach ($post->_event_organizer_ids as $key => $organizer_id) { // WPML Workaround for compsupp-6662 if (class_exists('SitePress')) { $organizer_id = apply_filters( 'wpml_object_id', $organizer_id, 'event_organizer', TRUE ); }
- Next, open the /wp-content/plugins/wp-event-manager/wp-event-manager-functions.php file.
- Look for line 1903.
- Change:
function get_event_organizer_ids( $post = null ) { $post = get_post( $post ); if ( $post->post_type !== 'event_listing' ) return; return !empty($post->_event_organizer_ids) ? $post->_event_organizer_ids : ''; }
To:
function get_event_organizer_ids( $post = null ) { $post = get_post( $post ); if ( $post->post_type !== 'event_listing' ) { return; } // WPML Workaround for compsupp-6662 if ( class_exists('SitePress') && !empty($post->_event_organizer_ids) ) { foreach ($post->_event_organizer_ids as $key => $organizer_id ) { $result = $post->_event_organizer_ids; $result[$key] = apply_filters( 'wpml_object_id', $organizer_id, 'event_organizer', TRUE ); } return $result; } return !empty($post->_event_organizer_ids) ? $post->_event_organizer_ids : ''; }
- Finally, in the same file, look for line 1985.
- Change:
function get_event_venue_ids( $post = null ) { $post = get_post( $post ); if ( $post->post_type !== 'event_listing' ) return; return !empty($post->_event_venue_ids) ? $post->_event_venue_ids : ''; }
To:
function get_event_venue_ids( $post = null ) { $post = get_post( $post ); if ( $post->post_type !== 'event_listing' ) return; // WPML Workaround for compsupp-6662 if ( class_exists('SitePress') && !empty($post->_event_venue_ids) ) { $result = apply_filters( 'wpml_object_id', $post->_event_venue_ids , 'event_listing', TRUE ); return $result; } return !empty($post->_event_venue_ids) ? $post->_event_venue_ids : ''; }