Toolset Types
[Plugin: Types - Custom Fields and Custom Post Types Management] Query events by date - custom field (2 posts)

  1. micks800
    Posted 3 years ago #

    I have a custom field 'event-date' and I would like to only upcoming events which has event-date>today. I tried a lot but not able to make the query, can you please help?

    This is my current query -
    query_posts(array( 'post_type' => 'events','type' => 'party' ));
    if ( have_posts() ) : while ( have_posts() ) : the_post();

    The query_posts is not accepting custom fields. I tried WP_Query but it's not working either.



  2. Amir Helzer
    Plugin Author

    Posted 3 years ago #

    Until someone else jumps in and explains how to do this in PHP, using the correct WordPress API functions, would you like to see how Views does this?

    Have a look at Views date filters:

    Using Views, you would create a new View for the 'events' custom post type. Then, filter it according to upcoming events.

    We're missing a feature to add date filtering according to values of custom fields of the current post. We'll try to include that in the next Views release. Now, you can filter by fixed dates, or relative to the current date.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Toolset Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.