Last active
August 21, 2019 10:35
-
-
Save djrmom/5eb22e4f3ea4b0fad3876a6d95b31974 to your computer and use it in GitHub Desktop.
facetwp redirect on marker click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* redirect to permalink on click of info marker instead of opening info window | |
* Use the_permalink as the only content of your map facet marker content setting | |
* https://d.pr/i/TTb4XW | |
*/ | |
add_action( 'wp_footer', function() { ?> | |
<style> | |
.gm-style .gm-style-iw-a {display: none;} | |
</style> | |
<script> | |
(function($) { | |
if ('object' !== typeof FWP) { | |
return; | |
} | |
$(function() { | |
FWP.hooks.addAction('facetwp_map/marker/click', function( marker ) { | |
window.location.href = marker.content; | |
}); | |
}); | |
})(jQuery) | |
</script> | |
<?php }, 100 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* redirect by post_id, this will use the non-prettyperamlink url | |
* but there is no need to change marker content | |
*/ | |
add_action( 'wp_footer', function() { ?> | |
<script> | |
(function($) { | |
if ('object' !== typeof FWP) { | |
return; | |
} | |
$(function() { | |
FWP.hooks.addAction('facetwp_map/marker/click', function( marker ) { | |
window.location.href = '<?php echo home_url( '?p=' ); ?>' + marker.post_id; | |
}); | |
FWP.hooks.addAction('facetwp_map/marker/mouseover', function( marker ) { | |
FWP_MAP.infoWindow.setContent(marker.content); | |
FWP_MAP.infoWindow.open(FWP_MAP.map, marker); | |
}); | |
FWP.hooks.addAction('facetwp_map/marker/mouseout', function( marker ) { | |
FWP_MAP.infoWindow.close(); | |
}); | |
}); | |
})(jQuery) | |
</script> | |
<?php }, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment