Created
August 24, 2017 14:51
-
-
Save djrmom/5870f7baf38fd5df40ee861bb95a01d5 to your computer and use it in GitHub Desktop.
facetwp add view all radio button
This file contains hidden or 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
<?php | |
/** adds a "View All" index value to every post | |
** change 'my_radio' to the name of the radio facet to apply to | |
** 'View All' can be changed to whatever label is preferred | |
** reindex after add this code | |
**/ | |
add_filter( 'facetwp_indexer_row_data', function( $rows, $params ) { | |
if ( 'my_radio' == $params['facet']['name'] ) { | |
$new_row = $params['defaults']; | |
$new_row['facet_value'] = 'all'; | |
$new_row['facet_display_value'] = 'View All'; | |
$rows[] = $new_row; | |
} | |
return $rows; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment