-
AuthorPosts
-
June 26, 2015 at 12:05 pm #464895
Hi guys ,
I set a gallery masonry , which opened in an external link .
Im using portfolio entries and I would like that the connection is opened in a new window.
There is the possibility to open the title in a link different from that set for the photo?You can see here http://limodo.org/masonry-women/ in the last entry named “skirt”
TY
June 29, 2015 at 12:48 pm #465805Hey pistonluca!
Please add following code to Functions.php file in Appearance > Editor
function add_custom_target(){ ?> <script> jQuery(window).load(function(){ jQuery('.home #av-masonry-1 a').attr('target','_blank'); }); </script> <?php } add_action('wp_footer', 'add_custom_target');
Best regards,
YigitJuly 23, 2015 at 9:10 am #477567Hello Yigit,
I don’t think this code would work for me. You see, I only need target=”_blank” IF the link is to an External URL. ( I am not a programmer, but I don’t think it will work for External link Only – correct?)
I set Some of my posts with the Yoast 301 redirect – if the post is something published in another website.
Additionally it is not clear to me Where in my functions.php file to add this type of code in.
Thank youJuly 24, 2015 at 10:04 pm #478402Hi!
Try changing the code to this:
function add_custom_target(){ ?> <script> jQuery(window).load(function(){ jQuery('.home #av-masonry-1 a:not([href^="http://limodo.org"]):not([href^="#"]):not([href^="/"])').attr('target','_blank'); }); </script> <?php } add_action('wp_footer', 'add_custom_target');
Putting at the end will do the job.
Cheers!
JosueJuly 28, 2015 at 8:23 am #479496Thank you Josue for your quick response.
I tried placing the above code at the bottom of my functions.php file, I cleared my cache and refreshed, and – no change…..I did change limodo.org to my URL. Additionally, I’m not sure what the significance in my case ” add_action(‘wp_footer’, ‘add_custom_target’);” is. So I tried to remove it as well, that did not work either.
I tried this nice little script as well, ( I added it with a “add to header ” plugin ) It did not work
<script>
$(document).ready(function() {
$( ‘a[href^=”http://”%5D’ )
.attr( ‘target’,’_blank’ )
.addClass( ‘external_link’ )
;
});
</script>The posts that need to open in a new tab ( some are displayed on the home page, some are on the blog page) have the “yoast” 301 redirect set to an external URL. They are blogs that the author wrote – on other sites. So while he wants to list them here with his blogs, they do need to open in a new Tab, on the site they are published.
Please Advise
Thank you again for your persistent assistance!July 28, 2015 at 8:49 am #479505Hi!
Please post a link to the Page containing the masonry you want to affect.
Cheers!
JosueJuly 28, 2015 at 9:39 am #479534http://webstrauss.com/ak/blog/
http://webstrauss.com/ak
There are some other pages as well, but I can just copy /edit the code you write . correct?
Thank you again!!July 28, 2015 at 9:47 am #479544I see, all blog links are within your domain and the “redirection” occurs later with a 301 rule, so there’s no way to identify these external links and apply the target attribute mod. You’ll need to re-think your approach, have you tried using Post formats (see “link” type)?
Best regards,
JosueJuly 29, 2015 at 12:16 am #479954Hey Josue!
Check this out!
this awesome plug in did the trick!!
Quick Page/Post Redirect Plugin
Thanks again!!
H -
AuthorPosts
- The topic ‘Ajax question’ is closed to new replies.