Sniplet modification
-
Hi there,
I have been playing around with a sniplet enabling me to use an external link to a customizr slider – and all is well if I only want 1 of the slides to link externally.
However I would like more slides to have extranal links, and unfortunatelly I’m a little lost when it comes to php modification, and this is why I’m now asking for help here.
The sniplet I have used are as follows:
function my_new_target() { return 'http://www.google.com'; } add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2); function my_slide_custom_link( $slide_link , $image_id ) { //does nothing if the image's id is not the targeted one if ( MY-IMAGE-ID != $image_id ) return $slide_link; add_action('wp_footer' , 'open_external_link_in_new_tab'); function open_external_link_in_new_tab() { ?> <script type="text/javascript"> jQuery(document).ready(function () { ! function ($) { var new_target = '<?php echo my_new_target() ?>'; //prevents js conflicts "use strict"; console.log(new_target); //checks if the target slide url exists first if ( $('a[href="<?php echo my_new_target() ?>"]' , '#customizr-slider' ).length === 0 ) return; //adds the new button html content after the original button $('a[href="<?php echo my_new_target() ?>"]' , '#customizr-slider').attr('target' , '_blank'); }(window.jQuery) }); </script> <?php } //sets a custom url for the targeted slide return my_new_target(); }
Any suggestions on how to modify this so I can add more ID’s and external links.
I thank you in advance
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Sniplet modification’ is closed to new replies.