• I’m trying to only display posts which have a date of today or are in the future.

    What would be the best way to check for the date being today or in the future?

Viewing 9 replies - 1 through 9 (of 9 total)
  • from your docs
    wp-admin/options-general.php?page=ccs_reference&tab=loop

    it’s not detailed, but does after=future work?

    I’m guessing based on these 2 bits of info
    Published Date: after - display posts after a date
    and
    Date Field: value - future: today and after

    maybe they’re not connected though

    I used the following to display future events:

    [raw]<div class="eventscoming">
     [loop type=event count=12 field=wpcf-date value=future-time in=timestamp order=asc orderby=field_num offset=1]
     <div class="eventbox">
      <h3>[field title-link]</h3>
      <date>[field wpcf-date in=timestamp date_format="D j M Y @ g:ia"]</date>
      <div class="eventimage">[field image-link size=medium]</div>
      [link url]More...[/link]
     </div>
    [/loop]
    </div>[/raw]

    event is a custom post type, and would be replaced by “post” for regular posts.
    wpcf-date is a custom field holding the upcoming dates. For regular posts, I guess this is substututed with “date” which is the post’s date field.

    • This reply was modified 3 years, 9 months ago by iantresman.
    • This reply was modified 3 years, 9 months ago by iantresman.

    If the event should be in the future and today:

    [loop type=YOUR_TYPE field=YOUR_DATE_FIELD value=future .....]

    if future but not not today:

    [loop type=YOUR_TYPE field=YOUR_DATE_FIELD value='future not today' .....]

    • This reply was modified 3 years, 9 months ago by polarracing.
    • This reply was modified 3 years, 9 months ago by polarracing.
    • This reply was modified 3 years, 9 months ago by polarracing.

    Hi @polarracing

    if it’s 2pm now but the published date was 9am this morning, will future include it?

    or does future mean “from this point onwards”?

    if it’s the latter can you do today and future

    thanks

    As only the date is checked – future means today and from there on.

    If you need it on an hourly level use future-time

    Thread Starter Craig

    (@cpfusion)

    Thanks for all your input guys.

    I have played around with this awesome plugin a bit over the last few days and it seems that it can be as simple as this to achieve what I am looking for…

    [if field=wpcf-online-event-date after=yesterday in=timestamp]
    [field wpcf-online-event-date in=timestamp date_format="l j F"]
    Today, or Date in the Future
    [/if]
    
    [if field=wpcf-online-event-date before=today in=timestamp]
    [field wpcf-online-event-date in=timestamp date_format="l j F"]
    Date which has passed
    [/if]

    😃

    Ok, next time you could specify, that you want to achieve this in a [if] clause.

    All our suggestions was for a [loop].

    🙂

    Thread Starter Craig

    (@cpfusion)

    @polarracing sorry, noted. I should have been more explicit, but it was both you and @codemonkeynorth’s suggestions that led me to getting my head around using CCS and realising what a powerful tool it is.

    I have no issue with that, its just easier to point the finger to the issue.

    Yeah, its a great tool. I use it to run a multi language site. It saves from playing around with templates, queries and php code.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Greater than or equal to today’ is closed to new replies.