facetwp beaver builder masonry

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/**
** re-run masonry layout for beaver builder masonry post module after refreshing facets
**/
add_action( ‘wp_head’, function() { ?>

<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
var $element = ‘undefined’ == typeof element ? $( ‘body’ ) : $( element ),
msnryContent = $element.find(‘.masonry’);
if ( msnryContent.length ) {
msnryContent.masonry(‘layout’);
}
});
})(jQuery);
</script>

<?php } );
{{/gist}}