Past Events and Advanced Custom Fields
-
Hello.
I am using Advanced Custom fields relationship query to pull in a set of posts and events together on the homepage of my website. These are time sensitive posts and events. The posts have expiration dates on them and get converted to drafts, and then I have a filter on my ACF relationship to only show published posts. This function works perfect, but because past events are still published events, past events are showing up in my query. I need to have posts and events combined. Is there a way to only show future events in my ACF relationship query?
This is the function:
function relationship_options_filter($options, $field, $the_post) { $options['post_status'] = array('publish'); return $options; } add_filter('acf/fields/relationship/query', 'relationship_options_filter', 10, 3);
This is the ACF relationship query code
<?php foreach($home_blocks as $r): ?> <?php if ($r->post_status == 'publish'): ?> <div class="slide"> <article class="image-post"> <?php global $post; $post = $r; setup_postdata($post); ?> <?php the_post_thumbnail('thumbnail_368x184'); ?> <div class="caption"> <h1><?php the_title(); ?></h1> <?php dynamic_excerpt(100) ?> <a href="<?php the_permalink(); ?>" class="more"><?php _e('+ read more'); ?></a>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Past Events and Advanced Custom Fields’ is closed to new replies.