facetwp redirect on marker click

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?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 );
{{/gist}}{{gist file=”custom-hooks2.php” lang=”php”}}
<?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 );
{{/gist}}