Skip Navigation

[Resolved] Toolset View-Ajax pagination not showing correct lang after pagination action

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 3 voices.

Last updated by Waqar 11 months, 2 weeks ago.

Assisted by: Waqar.

Author
Posts
#2671775
secondary-language-front-end.png
EN-front-end.png
event-view-after-pagination action.png
ajax-pagination.png

Hi,

We are using the Events Calendar Pro + Toolset Views + WPML plugins to create a event directory (a view listing all the events created with Events Calendar Pro).

In the event view, it show some details about the event, such as the date (start + end), venue (built in from Events Calendar Pro), regions (custom taxonomy created with Toolset), audiences (custom taxonomy created with Toolset), etc..
The view is using AJAX pagination (using this option 'Pagination enabled with manual transition and AJAX' - screenshot attached: ajax-pagination.png). For now, we have only translated the Event Venue using the WPML plugin.

When you land on the Event directory page, it will show the first 2 events, and if you click on the 'load more' button, it will load the next 2 events. It's working on the English side, but on the secondary language side, it's not displaying the correct language after clicking the 'load more' button.
On the secondary language side, when you land on the page, it's displaying the correct language translation for the Event Venue, but if you click on the 'load more' button, it starts to show the English translations (screenshot attached: event-view-after-pagination action.png).

The 3rd + 4th event will be displayed after pagination action, and the Event Venue for those should be the same as the 2nd event venue (which is Venue ID: 3889) ᑲᖏᖅᖠᓂᖅ. However, it's displaying the English translation ((Venue ID: 3183) Rankin Inlet).
For some reason, it's grabbing the English venue ID (#3183), but the secondary language Venue ID for 'Rankin Inlet' should be #3889. I have attached some screenshots (EN-front-end.png + secondary-language-front-end.png)

Currently on the English side:
-Event 1: (Venue ID: 3220) Arviat
-Event 2: (Venue ID: 3183) Rankin Inlet
-Event 3: (Venue ID: 3183) Rankin Inlet
-Event 4: (Venue ID: 3183) Rankin Inlet

Currently on the Secondary language side:
Event 1: (Venue ID: 3870) ᐊᕐᕕᐊᑦ -- this is correct
Event 2: (Venue ID: 3889) ᑲᖏᖅᖠᓂᖅ -- this is correct
Event 3: (Venue ID: 3183) Rankin Inlet -- this is not correct
Event 4: (Venue ID: 3183) Rankin Inlet - this is not correct

I did try to use a pagination nav that doesn't use AJAX and it works fine. It's displaying the venue language correctly when going to the next page. It just doesn't work when using AJAX.

How can we fix this issue if we want to keep using ajax for paginations?

Thank you!

#2671931

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I think the issue may be that you need to update WPML settings to set a language cookie for ajax operations.

Go to WPML > Languages and check the "Language filtering for AJAX operations" setting.

#2671951
Screenshot 2023-12-08 092044.png

Hi Nigel,

"Language filtering for AJAX operations" was already enabled before I post this issue. I tried disabling and re-enabling it, still no luck.

#2672479

Hi,

Thank you for sharing this update.

Can you please share temporary admin login details, along with the link to the page, where this view can be seen? I'll also need your permission to download a clone/snapshot of the website, in case it needs to be investigated on a different server.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2673879

Hi, Just want to follow up on this. thanks!

#2674207

Thank you for sharing these details.

Just wanted to let you know that I'm still working on this and will share the findings, by the end of the day today.

Thank you for your patience.

#2674407

Thank you for waiting, while I completed the testing around this.

Because the events plugin stores the value of the venue post ID, as a custom field value, you'll need a custom shortcode that can correctly get the the venue information from that field, based on the current language.

For example:


add_shortcode('custom_translated_venue', 'custom_translated_venue_func');
function custom_translated_venue_func($atts) {
	global $post;

	$a = shortcode_atts( array(
		'return' => '',
	), $atts );
	
	$venue_id_val = get_post_meta( $post->ID, '_EventVenueID', true );

	$target_id = apply_filters( 'wpml_object_id', $venue_id_val, 'tribe_venue' );

	if ($a['return'] == 'title') {
		return get_the_title($target_id);
	}
	else {
		return $target_id;
	}
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

After that you'll be able to call the venue's ID and/or venue's title through this new shortcode, like this:


Venue ID: [custom_translated_venue]
Venue Title: [custom_translated_venue return="title"]

#2674847

Thank you Waqar for looking into this issue! It works!