
-
AuthorPosts
-
January 20, 2019 at 7:31 pm #1056267
I want one of my masonry galleries to open the provided custom link in a new tab
I followed instructions in another thread and it worked but then the blog posts in another masonry I have on my site also opened in a new tab (which is not the idea).
Any ideas how to overcome this?
Thanks!January 20, 2019 at 7:55 pm #1056271can you link to the page/post where you have that other thread?
if it is by using the method to add the target blank thing.you can do it via an if clause for that page.
Or you give a custom class to the masonry ALB Element f.e. newtaband then the jquery code would be for child-theme functions.php
function open_masonry_in_tab(){ ?> <script> (function($){ $(window).load(function() { $('.av-masonry.newtab .av-masonry-entry').attr('target', '_blank'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'open_masonry_in_tab');
January 20, 2019 at 8:02 pm #1056274I tried what this thread suggested by pasting the code on my functions.php
-
This reply was modified 6 years, 1 month ago by
saracoet.
January 20, 2019 at 8:06 pm #1056277ok – then i misunderstood you.
You got a masonry with no lightbox. But there are custom links on some images – and these have to open in new tab.January 20, 2019 at 8:07 pm #1056278thats right, sorry if I didn’t express myself correctly
-
This reply was modified 6 years, 1 month ago by
saracoet.
January 20, 2019 at 8:14 pm #1056283so you used ismaels code?
and if this only on a specific page it would be nice to use it with an if clause on that page – because the script is then not loaded on the other pages.
( i just changed the function name to know better what is influenced on the script):add_action('wp_footer', 'open_customlinks_in_masonry_in_newtab'); function open_customlinks_in_masonry_in_newtab(){ if( is_page(35) ) { ?> <script type="text/javascript"> (function($) { function a() { $('.av-masonry-entry:not(".lightbox-added")').each( function() { $(this).attr('target', '_blank'); $(this).attr('rel', 'nofollow'); }); } a(); })(jQuery); </script> <?php } }
so you have to know the ID of your page.
Or if you use it with a custom class ( like above mentioned: newtab )
add_action('wp_footer', 'open_customlinks_in_masonry_in_newtab'); function open_customlinks_in_masonry_in_newtab(){ ?> <script type="text/javascript"> (function($) { function a() { $('.av-masonry.newtab .av-masonry-entry:not(".lightbox-added")').each( function() { $(this).attr('target', '_blank'); $(this).attr('rel', 'nofollow'); }); } a(); })(jQuery); </script> <?php }
then you have to give the masonry ALB that class
January 20, 2019 at 9:27 pm #1056325Thanks for taking the time, I really appreciate it!
the 2 masonries I use are on the same page, one is for blog posts and the other just an image gallery with links to other sites
I want the blog posts from one masonry to open on the same tab but the ones from the image gallery with external links to open on a new tab.
Since they are both on the same page, just to make sure I understand, you suggest I paste the 2nd code you provided in the Quick CSS and add “newtab” on the image gallery Masonry’s css class?I’ve tried it and it doesn’t seem to work
Should I add the code to the functions.php via ftp or does that have the same result as adding the code to the Quick CSS?
Sorry, I’m quite new to this :9
-
This reply was modified 6 years, 1 month ago by
saracoet.
January 20, 2019 at 9:41 pm #1056331but you said that it works fine with code from your link – so i thought you have done all right but only have troubles to select only one of them!
That code above ( and then you will need the second one) comes to child-theme functions.php
you will come to functions.php via dashboard – appearance – editor on the right there are “Theme files” click on functions.php
All those snippets here from Board mostly comes to this file except css code ( which comes on common to quick css ).If you are not running a child-theme – you have here a lot of Theme files – and a function.php too.
You can edit too – but you have to place those codes just after the comment lines on the bottom of the file:/* * register custom functions that are not related to the framework but necessary for the theme to run */
these custom snippets are lost everytime you update enfold – that is the reason for a child-theme use
If it is placed – give a custom Class to the masonry where you want to have that new effect.
Custom Class – you know how to activate the input field on Enfold.?
January 21, 2019 at 12:58 am #1056370Thanks I will look into child theme because I am not familiar with that.
Thanks a lot for your help, I will let you know how it goesJanuary 21, 2019 at 6:12 am #1056428 -
This reply was modified 6 years, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.