Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created November 16, 2017 16:02
Show Gist options
  • Save djrmom/8bcdf5f26bb6453025285f1c305e2f42 to your computer and use it in GitHub Desktop.
Save djrmom/8bcdf5f26bb6453025285f1c305e2f42 to your computer and use it in GitHub Desktop.
facetwp selected facets
<?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; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment