Skip to content

Instantly share code, notes, and snippets.

@f3bruary
Created September 21, 2022 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f3bruary/1bd04dcfcab840749c9ffe3478a644ec to your computer and use it in GitHub Desktop.
Save f3bruary/1bd04dcfcab840749c9ffe3478a644ec to your computer and use it in GitHub Desktop.
FacetWP: Register facets programmatically (via code)
<?php
/* updated 2022-09-21 */
$facets = [
[
'name' => 'test_checkboxes',
'label' => 'Test checkboxes',
'type' => 'checkboxes',
'source' => 'post_type',
'parent_term' => '',
'hierarchical' => 'no',
'show_expanded' => 'no',
'ghosts' => 'no',
'preserve_ghosts' => 'no',
'operator' => 'and',
'orderby' => 'count',
'count' => '10',
'soft_limit' => '5'
],
[
'name' => 'test_dropdown',
'label' => 'Test dropdown',
'type' => 'dropdown',
'source' => 'post_type',
'parent_term' => '',
'hierarchical' => 'no',
'orderby' => 'count',
'count' => '20',
'label_any' => 'Any'
],
[
'name' => 'test_fselect',
'label' => 'Test fSelect',
'type' => 'fselect',
'source' => 'post_type',
'parent_term' => '',
'hierarchical' => 'no',
'ghosts' => 'no',
'preserve_ghosts' => 'no',
'operator' => 'and',
'orderby' => 'count',
'count' => '10',
'label_any' => 'Any',
'multiple' => 'no'
],
[
'name' => 'test_hierarchy',
'label' => 'Test hierarchy',
'type' => 'checkboxes',
'source' => 'post_type',
'parent_term' => '',
'hierarchical' => 'no',
'show_expanded' => 'no',
'ghosts' => 'no',
'preserve_ghosts' => 'no',
'operator' => 'and',
'orderby' => 'count',
'count' => '10',
'soft_limit' => '5'
],
[
'name' => 'test_search',
'label' => 'Test search',
'type' => 'search',
'source' => 'post_type',
'search_engine' => '',
'placeholder' => '',
'auto_refresh' => 'no'
],
[
'name' => 'test_autocomplete',
'label' => 'Test autocomplete',
'type' => 'autocomplete',
'source' => 'post_type',
'placeholder' => ''
],
[
'name' => 'test_slider',
'label' => 'Test slider',
'type' => 'slider',
'source' => 'post_type',
'compare_type' => '',
'prefix' => '',
'suffix' => '',
'format' => '0,0',
'step' => '1',
'source_other' => ''
],
[
'name' => 'test_date_range',
'label' => 'Test date range',
'type' => 'date_range',
'source' => 'post_type',
'compare_type' => '',
'fields' => 'both',
'format' => '',
'source_other' => ''
],
[
'name' => 'test_number_range',
'label' => 'Test number range',
'type' => 'number_range',
'source' => 'post_type',
'fields' => 'both',
'compare_type' => '',
'source_other' => ''
],
[
'name' => 'test_proximity',
'label' => 'Test proximity',
'type' => 'proximity',
'source' => 'post_type',
'unit' => 'mi',
'radius_ui' => 'dropdown',
'radius_options' => '10, 25, 50, 100, 250',
'radius_min' => '1',
'radius_max' => '50',
'radius_default' => '25',
'source_other' => ''
],
[
'name' => 'test_radio',
'label' => 'Test radio',
'type' => 'radio',
'source' => 'post_type',
'parent_term' => '',
'ghosts' => 'no',
'preserve_ghosts' => 'no',
'operator' => 'or',
'orderby' => 'count',
'count' => '20'
],
[
'name' => 'test_star_rating',
'label' => 'Test star rating',
'type' => 'rating',
'source' => 'post_type'
],
[
"label" => "Load More",
"name" => "loadmore",
"type" => "pager",
"pager_type" => "load_more",
"load_more_text" => "Load more...",
"loading_text" => "Fetching...",
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment