JS code embed in PRO

Hi,

I got a request from a client and he got it from a city council. They need to embed a JS news block into their home page. So there is some JS code which I entered into the page Custom JS settings, some CSS which I added to page Custom CSS settings and HTML code which I entered into the text (but that also might be a content) block inside the page. But the problem is that I can see the block content only when I am logged-in. As soon as I log out the block is empty. Could you please help me to identify what is wrong here?

Hi there,

Actually, your approach seems to be a correct one and I am not sure why the Javascript code is not working. I checked my browser console and found out some socket errors and a Jetpack related one:

I suggest that you troubleshoot the case taking the steps below:

  • Purge all caches you may have
  • Disable all plugins
  • Check the case, if it is working then you need to activate plugins one by one to find which one is causing the issue.

Another way to check the case:

By the tests above you will find out there is a conflict with the Cornerstone or this is not related to our theme or builder at all and you need to investigate the code of the JS.

The point above are the ones that I could think of that might be the problem cause.

Hope it helps.

Hi,

The first option didn’t help. After cashes been cleared and all plugins disabled the behaviour of the function didn’t change anyhow.

In the second option, I have problems with understanding the first point. I have never used hooks. So I do not know how to put correctly in the functions.php of the child theme. I am pretty sure that I did second and third steps right.

I need to embed this JS: https://www.mos.ru/otrasli-static/outer/mosTizer.js

Hi there,

I went to your website and added the Javascript code to the functions.php of the child theme using the Appearance > Editor menu:

I purged the cache and the result is this:

Kindly clear your browser cache and you will see the section.

Thank you.

Hi @christopher.amirian,

Thanks, but from my side, the layout of the site looks completely broken now. Cash cleared both locally and at the server, but it didn’t help. Again it only looks OK when you logged in, but for the audience, it looks broken.

I had to delete your code and reset cash again. Let’s experiment with staging copy. I am to send you new credentials.

Hi,

I added the html code in raw content instead of text element and it seems to work.

Please check sport website in your end.

Thanks

Yes, thanks a lot.

I tried to use it with V2 elements but didn’t try classic elements as I thought to switch.

You’re welcome! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.