Created
January 14, 2016 21:01
-
-
Save mgibbs189/fd6cb767c093ff5de499 to your computer and use it in GitHub Desktop.
FacetWP - convert hard-coded links from hash-based permalinks to GET-based
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 | |
// Add to your theme's functions.php | |
function fwp_fix_links() { | |
?> | |
<script> | |
(function($) { | |
$(function() { | |
$('a[href*="/#!/"]').each(function() { | |
var href = $(this).attr('href'); | |
var new_href = href.split('/#!/'); | |
var url_vars = new_href[1].split('&').map(function(val) { | |
return 'fwp_' + val; | |
}); | |
new_href[1] = url_vars.join('&'); | |
$(this).attr('href', new_href.join('/?')); | |
}); | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
} | |
add_action( 'wp_head', 'fwp_fix_links', 50 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment