Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created January 14, 2016 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/fd6cb767c093ff5de499 to your computer and use it in GitHub Desktop.
Save mgibbs189/fd6cb767c093ff5de499 to your computer and use it in GitHub Desktop.
FacetWP - convert hard-coded links from hash-based permalinks to GET-based
<?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