-
AuthorPosts
-
February 8, 2017 at 9:05 pm #744493
Hi, I’m using the Masonry Gallery for different parts of my website however I need the gallery to open up some links in a new window and some in the same window.
For example on my home page the gallery opens a link in the same window however when I use the gallery on other pages I want the links to open in a new window/tab. I initially searched the forum and found the following code which makes the links to open in a new window however this makes the entire Masonry Gallery to open all links in a new window regardless of what page I use it in:
==================================
function add_custom_script(){
?>
<script>
jQuery(window).load(function(){
jQuery(‘.av-masonry a’).each(function(){
jQuery(this).attr(‘target’, ‘_blank’);
});
});
</script>
<?php
}
add_action(‘wp_footer’, ‘add_custom_script’);
==================================I would like to know if there is any solution to have either one of those options. I have included the sample pages in the PRIVATE CONTENT. I would appreciate if you guys can help me out regarding this issue.
Thanks again!
February 8, 2017 at 10:24 pm #744537Hi aliakbari2!
Can you please share us backend access so we can check your functions.php file?
Thanks a lot
Cheers!
BasilisFebruary 8, 2017 at 11:17 pm #744545Thanks for the reply, the login information is available in the PRIVATE CONTENT section.
February 13, 2017 at 6:22 pm #746553Hi again, were you able to login to the account to analyze the FUNCTIONS.php file by any chance? Thanks.
February 13, 2017 at 9:21 pm #746615Hi,
you could try to work with WordPress’ conditional functions:
https://codex.wordpress.org/Conditional_TagsBest regards,
AndyFebruary 22, 2017 at 3:52 pm #750530Hi,
you can target pagesfunction add_custom_target(){
?>
<script>
jQuery(window).load(function(){
jQuery(‘.page-id-xx .av-masonry-container a ‘).attr(‘target’,’_blank’);
});
</script>
<?php
}
add_action(‘wp_footer’, ‘add_custom_target’);February 27, 2017 at 4:51 pm #752351 -
AuthorPosts
- You must be logged in to reply to this topic.
