Tagged: java script, js
-
AuthorPosts
-
July 6, 2023 at 11:53 pm #1412644
Hello:
Let’s see if you can help me with the following question. My provider has given me a script code (1) to insert his player in the post you want. I inserted it in a post and it works fine, you can see it in the url below (2).
The thing is that I asked them if I could insert it en masse in all my posts. Below I indicate what they answered me. Well, I created a folder called ‘js’ in my Enfold Child and there I moved a js file with the player script. Then I put the following code inside my functions.php child (3), so that the js file is executed every time a post is opened, not a page. But it doesn’t work.
I would appreciate if you could look into it in case you can detect the reason why it doesn’t work.
Thank you very much and best regards,
Jose RamonP.S. At this moment the functions.php does not contain the code.
July 8, 2023 at 3:54 pm #1412733Hey Jose Ramon,
Thank you for your patience, I’m unable to test your code on my test site as apparently it will only work on your site, so we would need to login to your site to examine why it may not be working, Please include an admin login in the Private Content area so we can be of more assistance.Best regards,
MikeJuly 8, 2023 at 9:46 pm #1412778Hi Mike:
Thanks to you. Indeed, it only works from my domain. If your access connection is from somewhere other than Europe, please tell me the country to activate the access.
Best regards,
Jose RamonJuly 8, 2023 at 9:56 pm #1412782July 8, 2023 at 10:08 pm #1412785Hi, Mike:
Please check.Best Regards,
Jose RamonJuly 8, 2023 at 10:18 pm #1412786For ftp connection, if needed.
July 9, 2023 at 1:07 am #1412814Hi,
Thank you for the link to your site I tested the code they gave you and it is working, but the player is at the bottom of the page.
So to move this to just before the content on posts I created a shortcode for it by adding this to your child theme functions.php:function trinity_shortcode() { return "<script>const trinityScript = document.createElement('script'); trinityScript.setAttribute('fetchpriority', 'high'); trinityScript.src = 'https://trinitymedia.ai/player/trinity/2900013165/?pageURL=' + encodeURIComponent(window.location.href); document.currentScript.parentNode.insertBefore(trinityScript, document.currentScript);</script>"; } add_shortcode( 'trinity', 'trinity_shortcode' );
and then I added it to your page with this in your functions.php
function trinity_before_the_content( $content ) { if ( is_single() ) { $custom_content = '[trinity]'; $custom_content .= $content; return $custom_content; } else { return $content; } } add_filter( 'the_content', 'trinity_before_the_content' );
Now it shows before the content on your single posts, please check
Best regards,
MikeJuly 9, 2023 at 11:02 am #1412836Awesome! That’s what I wanted. Thank you very much, Mike.
Best regards,
José Ramón- This reply was modified 1 year, 5 months ago by Jose Ramon.
July 9, 2023 at 12:47 pm #1412846Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Running a js code’ is closed to new replies.