Support

Account

Home Forums General Issues ACF date field won’t work in excluding posts from loop

Unread

ACF date field won’t work in excluding posts from loop

  • Hi guys,

    I’m currently building a website where I need to show coming events. I’m building the website on the Salient WordPress theme, and trying to customize it a bit with some code in a child theme.

    I’m changing the build in blog post loop of the theme, to show events instead. Within the code I made some few changes to sort them in the correct order (nog publish date, but event date) but I can’t seem to figure out how to exclude events that have their date passed.

    ` if( $orderby !== ‘view_count’ ) {

    $today = date(‘l j F’);
    $nectar_blog_arr = array(
    ‘post_type’ => ‘evenement’,
    ‘posts_per_page’ => $posts_per_page,
    ‘post_status’ => ‘publish’,
    ‘meta-key’ => ‘event_startdate’,
    ‘meta_query’ => array(
    ‘relation’ => ‘AND’,
    ‘date_clause’ => array(
    ‘key’ => ‘event_startdate’,
    ‘value’ => $today,
    ‘type’ => ‘DATE’,
    ‘compare’ => ‘>=’
    ),

    ),
    ‘orderby’ => array(
    ‘date_clause’ => ‘ASC’,
    ),
    ‘offset’ => $post_offset,
    ‘category_name’ => $category,
    ‘paged’ => $paged
    );`

    Any tips or tricks?

    Note: I tried many pieces of code that I found on this form, or other website, but some codes just breaks the loop, and won’t show the loop at all. Without any PHP errors as well. Weird right?

    Thanks in advance for all the help and suggestions!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.