Created
July 4, 2024 07:36
-
-
Save tdmrhn/616ac7df6e757730dad2ecd3461094aa to your computer and use it in GitHub Desktop.
Blocksy Posts Shortcode Add Years arg
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
<?php | |
add_filter('blocksy:general:shortcodes:blocksy-posts:args', function ($query_args, $shortcode_args) { | |
if (isset($shortcode_args['years'])) { | |
$years = array_map('intval', explode(',', $shortcode_args['years'])); | |
$query_args['date_query'] = array( | |
'relation' => 'OR', | |
array_map(function ($year) { | |
return array('year' => $year); | |
}, $years) | |
); | |
} | |
return $query_args; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment