Title: Does not load pages based on language
Last modified: January 23, 2024

---

# Does not load pages based on language

 *  [mik777em](https://wordpress.org/support/users/mik777em/)
 * (@mik777em)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/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:**
 * ![](https://i0.wp.com/i.ibb.co/hCRCKg5/1e.png?ssl=1)
 * On **ru** page plugin loads pages with url **not in Russian** _(not yet finalized
   on ru replacement)_:
 * ![](https://i0.wp.com/i.ibb.co/ZS5SDQR/2e.png?ssl=1)
 * 
   **My code in a plugin custom js field:**
 * ![](https://i0.wp.com/i.ibb.co/GCXfyrC/3q.png?ssl=1)
 * **Code:**
 *     ```wp-block-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/](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/](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](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/balbabla](https://transscreen.ru/pt/balbabla)**
 * where **balbabla**– Any text
    -  This topic was modified 2 years, 3 months ago by [mik777em](https://wordpress.org/support/users/mik777em/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdoes-not-load-pages-based-on-language%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘Does not load pages based on language’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 0 replies
 * 1 participant
 * Last reply from: [mik777em](https://wordpress.org/support/users/mik777em/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/does-not-load-pages-based-on-language/)
 * Status: not resolved