Ask your WordPress questions! Pay money and get answers fast! (more info)

Wordpress Events and Countries In the Future WordPress

I have set up a custom post type 'Events', along with a Custom Taxonomy 'Countries'.

I have also added an advanced custom field called Event Date.

I would like to display only the posts that are set in the future of the Event Date. I would also like to list out the countries with links for only taxonomy terms associated with posts in the future of the Event Date.

I have been trying to figure this out for days! please someone help :)

Thanks

Answers (1)

2015-06-29

Francisco Javier Carazo Gil answers:

Hello Codeme,

Try it:
<blockquote>display only the posts that are set in the future of the Event Date.</blockquote>

The code:
$today = date('Ymd');
$args = array(
'post_type' => 'event',
'posts_per_page' => '-1',
'meta_key' => 'the_date',
'meta_query' => array(
array(
'key' => 'the_date',
'value' => $today,
'compare' => '>='
)
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);


Francisco Javier Carazo Gil comments:

And for this:

<blockquote>I would also like to list out the countries with links for only taxonomy terms associated with posts in the future of the Event Date.</blockquote>

You will have to do some kind of loop:
1) With get_terms you get a list of them and you can loop over taxonomy
2) In each taxonomy you do a query including this tax


codeme comments:

Hello Francisco,

I have tried this but it doesn't seem to work, you have used 'the_date', what is this? I have used an advanced custom field date picker to store the event Start Date, its called start_date.

The more pressing matter as explained above is getting the taxonomy terms to display only for posts that are in the future.

Let me know if you have any questions.


codeme comments:

Just saw your second post.

get_terms will get every term associated with the taxonomy, it will not get terms based on posts start date, which is what I need.


Francisco Javier Carazo Gil comments:

For $1 I cannot do much more, if you need personal help, I can help and explain you.