Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Hello, I’m wondering have you inspected your site to make sure the nlp_extlinks.js is being correctly loaded?

    Thread Starter jzvestor

    (@jzvestor)

    Thread Starter jzvestor

    (@jzvestor)

    the bottom section is pulling from the network:
    From the Trailhead
    https://trailsherpa.com

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    I’ve just inspected your site, there are two issues that must be addressed in order for the script to work:

    1.- Your site is incorrectly linking to the JavaScript file, right now it’s pointing to:

    https://www.trailsherpa.com/%3C?php%20echo%20get_template_directory_uri();%20?%3E/js/nlp_extlinks.js

    When it should be pointing to:

    https://trailsherpa.com/wp-content/themes/trailsherpadev/js/nlp_extlinks.js

    Please check the PHP file (functions.php I believe) to delete <?php and ?> tags.

    2.- You are using blocks instead of lists so the JavaScript file must be tweaked to reflect so:

    // Actual JavaScript Document
    jQuery(document).ready(function(){
        jQuery('.nlposts-ulist-litem h3 a').attr('target', '_blank');
    });
    
    // This is the one you need
    jQuery(document).ready(function(){
        jQuery('.nlposts-block-litem h3 a').attr('target', '_blank');
    });

    Looking forward to your feedback.

    Thread Starter jzvestor

    (@jzvestor)

    can I just say, WOW on the support for this plugin!

    Ok, I have updated the js file call in the head to read:
    <script type="text/javascript" src="https://trailsherpa.com/wp-content/themes/trailsherpadev/js/nlp_extlinks.js"></script>

    The nlp_extlinks.js file now reads:

    jQuery(document).ready(function(){
        jQuery('.nlposts-block-litem h3 a').attr('target', '_blank');
    });

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    But, it is still loading in the original window…

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Hi, indeed the file is now correctly linked. However, there’s another issue, you see this script depends on jQuery to work, the thing is your site is loading jQuery within the body tag and you’re linking the nlp_extlinks.js in header.

    Could you please change your templates or functions to load the nlp_extlinks.js in your site’s footer instead of header? If you’re doing it through a WordPress hook you should use ‘wp_footer’ instead of ‘wp_head’ something like this:

    function nlp_extlinks() {
         wp_enqueue_script(
    		'nlp_extlinks',
    		get_stylesheet_directory_uri() . '/js/nlp_extlinks.js',
    		array( 'jquery' )
    	);
    }
    add_action( 'wp_footer', 'nlp_extlinks' );

    Let me know if it works.

    Thread Starter jzvestor

    (@jzvestor)

    still doesn’t seem to be. I tried adding the above to my functions.php

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Hi,

    Ok I see it’s loading where it should be. However I just noticed I did a mistake on the JavaScript code sorry, could you please replace the nlp_extlinks.js content by the code below?

    jQuery(document).ready(function(){
        jQuery('.nlposts-block-thumbnail-litem a').attr('target', '_blank');
    });

    This time it should work.

    Thread Starter jzvestor

    (@jzvestor)

    nope, not quite….sorry!

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Yes it’s working now, I’ve just checked in your site. Please refresh your browser or delete cache. It seems you’re still getting a cached version of the previous script.

    Cheers.

    Thread Starter jzvestor

    (@jzvestor)

    Yes! You’re right!! thank for you the EXCELLENT support!!

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    I’m glad everything is working now.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘open links in new window’ is closed to new replies.