facetwp output facet links instead of taxonomy links

djrmom

{{gist file=”display.php” lang=”php”}}
<?php
/** basic output of using facet links instead of taxonomy archive
** change ‘my_taxonomy_name’, ‘fwp_my_facet_name’, ‘http://example.com/page_for_facets/’
** note that if using facetwp_index_row or facetwp_indexer_row_data to change the facetwp_value
** this would not work out of the box
**/
$terms = get_the_terms( get_the_ID(), ‘my_taxonomy_name’ );
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
foreach ( $terms AS $term ) {
$name = $term->name;
$link = add_query_arg( ‘fwp_my_facet_name’, FWP()->helper->safe_value( $term->slug ), ‘http://example.com/page_for_facets/’ );
echo “<a href=’$link’>$name</a><br />”; // very basic output of link, change as need
}
}
{{/gist}}