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!

  • Do you mean filtering the post_date field? Is "current day" = today? – birgire Dec 9 '15 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 Dec 9 '15 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 Dec 9 '15 at 13:20
  • Thanks, I have just done that, That's a good idea, thanks for your input :-) – Lucy Brown Dec 9 '15 at 13:24
  • 1
    see this one helpfull : wordpress.stackexchange.com/questions/52070/… – ravi patel Dec 9 '15 at 13:26
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, privacy policy and cookie policy

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