Tagged: ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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 Ramon

    P.S. At this moment the functions.php does not contain the code.

    #1412733

    Hey 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,
    Mike

    #1412778

    Hi 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 Ramon

    #1412782

    Hi,
    Please see below

    Best regards,
    Mike

    #1412785

    Hi, Mike:
    Please check.

    Best Regards,
    Jose Ramon

    #1412786

    For ftp connection, if needed.

    #1412814

    Hi,
    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,
    Mike

    #1412836

    Awesome! 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.
    #1412846

    Hi,
    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

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Running a js code’ is closed to new replies.