facetwp selected facets

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
$selected_alpha = ”;
if ( isset( FWP()->facet->facets[‘titles’][‘selected_values’] ) ) {
$alpha = FWP()->facet->facets[‘titles’][‘selected_values’];
$selected_alpha = array_shift( $alpha );
}

while ( have_posts() ) : the_post(); ?>

<div id=”downloads”>
<?php
// loop through rows (parent repeater)
while( have_rows(‘downloads’) ): the_row(); ?>
<li>
<?php
$file = get_sub_field(‘file_name’);
$folder = get_sub_field(‘s2_member_folder’);
$title = get_sub_field(‘link_title’);
if ( empty( $selected_alpha ) || strtolower( $selected_alpha ) == strtolower( substr( $title, 0, 1 ) ) ) {
echo ‘<a href=”/?s2member_file_download=’ . $folder . “/” . $file . ‘ “>’ . $title . ‘</a>’;
}
?>
</li>
<?php endwhile; ?>
</div>
<?php endwhile; ?>
{{/gist}}