JavaScript not loading when switching languages
-
Hello,
I was working on a website for a client (https://www.infiniacorp.com) and am using the Polylang plugin to switch between English, Spanish, and Italian.
The homepage pulls in static content from pages and as you can see on the English and Spanish versions, the drop-down menu and background slider work fine. However, on the Italian version, it does not.
Here is the custom PHP I am using to pull in the content from pages, and check which language the site is using:
<?php $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (false !== strpos($url,'es')): $page_id = 788; elseif (false !== strpos($url,'it')): $page_id = 1031; else: $page_id = 784; endif; ?> <?php $page_data = get_page( $page_id ); echo apply_filters('the_content', $page_data->post_content); ?>
This just checks what language code is in the URL, and sets the correct page ID for the given language. This code worked fine with just English and Spanish, but when I added Italian, it didn’t work completely.
Just to give you a little more background on my custom code, the background is supposed to be an image slider (this is not a theme I developed myself) so in the backend of WordPress I created multiple sliders for each language, and used this code to display them:
<?php $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (false !== strpos($url,'es')): //If spanish $featured_page_language = 808; elseif (false !== strpos($url,'it')): //If italian $featured_page_language = 1033; else: //If English $featured_page_language = $featured_page; endif; ?>
Very similar to the code above. It stores the ID of the slider and should display it, except it just doesn’t work for Italian.
All of the inner pages and everything work fine, it’s just this homepage that’s not doing it.
I would appreciate any help in fixing this, and thank you for developing such a great plugin. I would gladly shoot you over a donation if you could help me resolve this.
Best,
Keenan
- The topic ‘JavaScript not loading when switching languages’ is closed to new replies.