Last active
October 6, 2017 11:31
-
-
Save jackgregory/f200add35d95886d50416e0c35fa2c7e to your computer and use it in GitHub Desktop.
Listing Facets/Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function register_facets( $facets ) { | |
$facets[] = array( | |
'label' => __( 'Group', 'aplatform' ), | |
'name' => 'group', | |
'type' => 'fselect', | |
'multiple' => 'no', | |
'source' => 'acf/field_5s9a5l2s921df', // acf select field | |
'label_any' => __( 'everything', 'aplatform' ), | |
'orderby' => 'display_value', | |
'count' => '100', | |
'operator' => 'and', | |
); | |
$facets[] = array( | |
'label' => __( 'Type', 'aplatform' ), | |
'name' => 'type', | |
'type' => 'fselect', | |
'multiple' => 'no', | |
'source' => 'tax/listing_type', | |
'label_any' => __( 'everything', 'aplatform' ), | |
'orderby' => 'display_value', | |
'count' => '100', | |
'operator' => 'and', | |
); | |
$facets[] = array( | |
'label' => __( 'Feature', 'aplatform' ), | |
'name' => 'feature', | |
'type' => 'fselect', | |
'multiple' => 'yes', | |
'source' => 'tax/listing_feature', | |
'orderby' => 'display_value', | |
'operator' => 'or', | |
'count' => '100' | |
); | |
$facets[] = array( | |
'label' => __( 'Region', 'aplatform' ), | |
'name' => 'region', | |
'type' => 'fselect', | |
'multiple' => 'no', | |
'source' => 'tax/listing_region', | |
'label_any' => __( 'everywhere', 'aplatform' ), | |
'orderby' => 'display_value', | |
'count' => '100', | |
'operator' => 'and', | |
); | |
$facets[] = array( | |
'label' => __( 'Keywords', 'aplatform' ), | |
'name' => 'keyword', | |
'type' => 'search', | |
'search_engine' => '', | |
'placeholder' => __( 'Search', 'aplatform' ) | |
); | |
return $facets; | |
} | |
add_filter( 'facetwp_facets', 'register_facets' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return array( | |
'post_type' => 'listing', | |
'orderby' => array( 'menu_order' => 'ASC', 'date' => 'DESC' ), | |
'order' => 'asc', | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="listings"> | |
<?php | |
if ( have_posts() ) : | |
while ( have_posts() ) : the_post(); | |
// ap_get_template() function is just a wrapper for locate_template, passing variables to template files. | |
ap_get_template( 'partials/content-listing.php' ); | |
endwhile; | |
else : | |
ap_get_template( 'partials/content-none.php', array( | |
'message' => esc_html__( 'No listings found matching your search', 'aplatform' ) | |
) ); | |
endif; | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment