Does not load pages based on language
-
The code for the plugin AJAX Load More should load in infinite scroll, when approaching the bottom border of the page – pages based on the received language of the mother (the current loaded page).
But for some reason loads pages as without code, that is, in arbitrary languages.
For example, on the Portuguese page plugin loads pages in the bottom with url not in Portuguese:

On ru page plugin loads pages with url not in Russian (not yet finalized on ru replacement):

My code in a plugin custom js field:
Code:
console.log('Beginning of Ajax Load More script...'); // Get the path of the current URL var currentUrl = window.location.pathname; console.log('Current URL', currentUrl); // Regular expression for language code definition var languageRegex = /^\/(zh|tr|pt|ja|it|id|fr|es|en|de)\//; var languagePath = currentUrl.match(languageRegex) ? currentUrl.match(languageRegex)[1] : ''; if (!languagePath) { languagePath = 'ru'; console.log('Lang path: ru'); } else { console.log('Lang path:', languagePath); } // Function to modify Ajax Load More request before sending it window.almOnLoad = function(alm) { console.log('Before sending an Ajax Load More request'); // If the language code is present and not 'ru', modify the path for the AJAX request if(languagePath !== 'ru') { alm.ajaxurl = alm.ajaxurl.replace('/wp-admin/admin-ajax.php', '/' + languagePath + '/wp-admin/admin-ajax.php'); console.log('Modified AJAX request path:', alm.ajaxurl); } else { // If the code is 'ru' or absent, we use the standard AJAX request path console.log('Standard AJAX request path for Russian language.'); } }; console.log('Ajax Load More script is configured.');The solution to create pages in different languages, solved in this way: created separate pages / folders created independently of each other and exist independently.
There is Url https://transscreen.ru/news11043/ it means page in Russian language because there is no ru in it.
There is another independent page, which has another url like this: https://transscreen.ru/pt/news11043/ it is in Portuguese.In other words…. I have a very simple wish, for example I have page https://transscreen.ru/pt/balbabla– loaded, so at the bottom of it should plugin AJAX Load More load in general any pages from the site transscreen.ru, which in the url of this patern:
https://transscreen.ru/pt/balbablawhere balbabla– Any text
The page I need help with: [log in to see the link]
The topic ‘Does not load pages based on language’ is closed to new replies.