0

I have this query

<?php
        $post_args = array(
            'post_type' => 'tribe_events',
            'eventDisplay'=>'past',
            'tax_query' => array(

                array(
                    'taxonomy' => 'tribe_events_cat',
                    'field'    => 'slug',
                    'terms'    => 'compliance',
                    ),
                        ),

                        'meta_query' => array(
                            array(
                                'key' => 'associated_people',
                                'value' => $current_user,
                                'compare' => 'LIKE'
                        )
                    )
                ); ?>

It calls all events from the past but I need it to only pull past events that have dates from the last 12 months from the current day, is there any way I could do this?

I'm using the events calendar pro

Thanks for any help in advance!

6
  • Do you mean filtering the post_date field? Is "current day" = today?
    – birgire
    Commented Dec 9, 2015 at 12:58
  • Ah, I have missed out a vital piece of information! I am filtering the vents calendar at the moment, and I need to only show events that are in the last 12 months starting from the current day
    – Lucy Brown
    Commented Dec 9, 2015 at 13:00
  • Please add all information into the question. I guess the event date is stored as a custom field (post meta)? You could try to search this site for similar quesitons.
    – birgire
    Commented Dec 9, 2015 at 13:20
  • Thanks, I have just done that, That's a good idea, thanks for your input :-)
    – Lucy Brown
    Commented Dec 9, 2015 at 13:24
  • 1
    see this one helpfull : wordpress.stackexchange.com/questions/52070/…
    – Ravi Patel
    Commented Dec 9, 2015 at 13:26

1 Answer 1

1

This is how I did it in the end -

<?php
        $post_args = array(
            'post_type' => 'tribe_events',
            'eventDisplay'=>'custom',
            'start_date'     => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
            'tax_query' => array(

                array(
                    'taxonomy' => 'tribe_events_cat',
                    'field'    => 'slug',
                    'terms'    => 'management-leadership',
                    ),
                        ),

                        'meta_query' => array(
                            array(
                                'key' => 'associated_people',
                                'value' => $current_user,
                                'compare' => 'LIKE'
                        )
                    )
                ); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.