Filter out by custom field
-
I’m trying to use the relevanssi_do_not_index function to filter out posts that have expired via an ACF custom field, but I can’t seem to get it working. Every time I try to use the function then 0 posts get indexed.
This is the meta query I’m using to remove expired posts from my posts page:
‘key’ => ‘end_date’,
‘value’ => $todaysdate,
‘compare’ => ‘>=’,So I’ve tried this, but again it leaves the index at 0:
add_filter(‘relevanssi_do_not_index’, ‘rlv_exclude_exp’, 10, 2);
$todaysdate = date ( ‘Y-m-d’ );
$expire_date = get_field(‘end_date’, $post_id);function rlv_exclude_exp($exclude, $post_id) {
if ($expire_date >= $todaysdate) $exclude = true;
return $exclude;
}Any help would be appreciated ??
- The topic ‘Filter out by custom field’ is closed to new replies.