Skip to content

Instantly share code, notes, and snippets.

@djrmom
djrmom / custom-hooks.php
Created Aug 4, 2020
facetwp layout builder shortcodes
View custom-hooks.php
<?php
/** use do_shortcode on all layout builder items
** it is preferrable to target specific items
** as in https://facetwp.com/documentation/developers/output/facetwp_builder_item_value/
** if possible
**/
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
$value = do_shortcode( $value );
return $value;
@djrmom
djrmom / map.css
Created Jul 30, 2020
facetwp map facet css
View map.css
/** hide enable filtering button **/
.facetwp-map-filtering {
display: none;
}
/** hides map markers **/
.gm-style > div:first-of-type > div:first-of-type > div > div:nth-of-type(2) {
display: none;
}
@djrmom
djrmom / custom-hooks.php
Created Jul 29, 2020
facetwp create custom range dropdown
View custom-hooks.php
<?php
/** custom index to display a dropdown facet as a range
** change 'CHANGE_ME' to the name of your facet
** facet settings should be a dropdown type and the datasourc
** of the value you want to show as a range **/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'CHANGE_ME' == $params['facet_name'] ) {
$price = $params['facet_value'];
@djrmom
djrmom / facet.css
Created Jul 29, 2020
facetwp hide map markers with css
View facet.css
/** hides map markers on facetwp map facet with css **/
.gm-style > div:first-of-type > div:first-of-type > div > div:nth-of-type(2) {
display: none;
}
@djrmom
djrmom / custom-hooks.php
Last active Jul 28, 2020
facetwp copy range to dropdown
View custom-hooks.php
<?php
/** create a range list facet with the ranges you need
** create a dropdown facet with any datasource, post type is good its just a placeholder
** change the code below to match your facet names
**/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'my_range_facet' == $params['facet_name'] ) { // change 'my_range_facet' to the name of your range list facet
$params['facet_name'] = 'dropdown_range'; // trick FacetWP into saving values into the other facet
} elseif ( 'dropdown_range' == $params['facet_name'] ) { // change 'dropdown_range' to the name of your dropdown facet in this and the above line
@djrmom
djrmom / facet.js
Created Jul 17, 2020
facetwp prevents template change while still changing facets
View facet.js
$(function() {
FWP.hooks.addFilter('facetwp/template_html', function() {
return true;
}, 200 );
});
@djrmom
djrmom / facet.css
Created Jul 15, 2020
facetwp make more space for locate me icon on mobile
View facet.css
/** adjust as needed to fit mobile phones better **/
@media only screen and (max-width: 767px) {
#facetwp-radius {
display:block;
float: none;
width: 100%;
}
.location-wrap {
width: 100%
@djrmom
djrmom / facet.css
Last active Jul 15, 2020
facetwp checkbox styles
View facet.css
/** style checked label differently **/
.facetwp-type-checkboxes .facetwp-checkbox.checked {
color: red;
text-decoration: underline;
font-style: italic;
font-weight: bold;
}
/** basic example of inline row of checkboxes **/
.facetwp-type-checkboxes .facetwp-checkbox {
@djrmom
djrmom / facet.js
Last active Jul 30, 2020
facetwp set order of (or remove) flyout facets
View facet.js
(function($) {
if ('object' !== typeof FWP) {
return;
}
FWP.hooks.addFilter('facetwp/flyout/facets', function(facets) {
return ['facet3', 'facet1', 'facet2']; // change the facet display order
});
})(jQuery);
@djrmom
djrmom / flyout.html
Created Jul 13, 2020
facetwp add reset to flyout
View flyout.html
<div class="facetwp-flyout-tpl">
{content}
<button onclick="FWP.reset()">Reset</button>
</div>
You can’t perform that action at this time.