Tagged: custom link, masonry, new window
-
AuthorPosts
-
January 24, 2023 at 12:53 pm #1394910
I’ve set portfolio items to “define custom link”. On the page where I display the portfolio items I use the Masonry grid. When clicking on the item in the Masonry grid on frontend it opens the link in the same window. Is there a code to let the link open in a new window/tab?
Thanks in advance.
January 24, 2023 at 7:36 pm #1394989Hi YboS_2022,
Please try to check the answer on this thread: https://kriesi.at/support/topic/open-portfolio-link-in-a-new-window/#post-1287483
I hope it helps.Best regards,
NikkoJanuary 30, 2023 at 11:05 am #1395877Thanks for your help, but it doesn’t work.
I’ve put the code in the function.php file of the child theme. But the links are still opening in the same tab.January 30, 2023 at 1:11 pm #1395903Hi,
Thanks for the link to your page, I see that you are getting this error(index):279 Uncaught ReferenceError: jQuery is not defined
Please try this code instead at the end of your child theme functions.php file in Appearance ▸ Editor:function masonry_links () { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function ($) { $(document).ready (function () { var url = new RegExp(location.host); $('.av-masonry-entry').each(function () { if( ! url.test($(this).attr('href')) ) { $(this).attr('target', '_blank'); } }); }); }) (jQuery); }); </script> <?php } add_action ('wp_footer', 'masonry_links');If this doesn’t help, please include an admin login in the private content area so we can be of more assistance.
Best regards,
MikeJanuary 31, 2023 at 9:40 am #1395994Yes! Thank you very much. This code is working!
Issue solved.January 31, 2023 at 11:48 am #1396010Hi,
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 ‘How to: Masonry items open in a new window?’ is closed to new replies.
