skip to Main Content

Add Post Cards Sort by Date URL Filter

This function alters the theme elements such as the "Post Cards" so you can visit the URL like such: to display items only from 2016. This will work for any Total element that displays posts.

You can rename "sort_year" to anything you want except "year" because it will conflict with WordPress functions so it's best to keep it prefixed.

add_filter( 'vcex_query_args', function( $args, $atts ) {
	$year = ! empty( $_GET['sort_year'] ) ? esc_attr( $_GET['sort_year'] ) : '';

	if ( $year ) {
		$args['date_query'] = array(
			'year' => $year

	return $args;
}, 10, 2 );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)
Back To Top