Created
August 5, 2024 14:57
-
-
Save MarieComet/86756c71ba0746115df9b6e59944369c to your computer and use it in GitHub Desktop.
WP Grid Builder : Select of years of posts
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
| // Create a Select Facet with post date as data source | |
| function prefix_row_data( $row, $object_id, $facet ) { | |
| // If not facet ID "1". | |
| if ( 1 !== $facet['id'] ) { | |
| return $row; | |
| } | |
| $row['facet_value'] = date( 'Y', strtotime( $row['facet_value'] ) ); | |
| $row['facet_name'] = $row['facet_value']; | |
| return $row; | |
| } | |
| add_filter( 'wp_grid_builder/indexer/row', 'prefix_row_data', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment