• Hello,

    I have created a custom post type “Events” with some custom fields like “event_date”.

    How can I show these “Events” by using the “event_date” field?

    Currently, only posts will be displayed in the calendar, which are already published. Showing scheduled posts is not supported, that’s why I’d like to connect the calendar with the “event_date” field (Type: DATETIME).

    Any chance to help me with this?

    Thank you in advance and kind regards,
    Sascha

Viewing 4 replies - 1 through 4 (of 4 total)
  • I came here looking for a solution to the same problem, and since it seems several people ask for it every few months and doesn’t seem to exist, I made a dirty edit – and so far it seems to work OK. (you need to edit the plugin files for it to work, so it’ll have to be made again after every update, unfortunately – I don’t know how to do it better – perhaps someone will help with that)

    In the file wp-fullcalendar.php I edited the function ajax() and replaced 2 lines: (line 209-210 at the time I’m writing it)

    I replaced

    $post_date = substr($post->post_date, 0, 10);
    $post_timestamp = strtotime($post->post_date);

    with

    $post_date = substr(get_field(‘event_date’), 0, 10);
    $post_timestamp = strtotime(get_field(‘event_date’));

    Hi, @moocker. I’m really interested in getting this work for me. Unfortunately, events are not displayed with your code. I also followed @saschinger ‘s specifications (using a DATETIME field), but no success. I even corrected the quotation marks in your code for ', as follows:

    $post_date = substr(get_field('event_date'), 0, 10);
    $post_timestamp = strtotime(get_field
    ('event_date'));

    At this point, I’m lost. Oh, BTW, I’m trying to get this done with a custom field in Woocommerce’s “Product” CPT. Can your method be achievable with this CPT? Any help will be really appreciated.

    • This reply was modified 1 year, 7 months ago by codimex. Reason: format broken

    Hi @codimex

    I’m afraid I might be doo stupid to help here, I just hacked a solution that kinda worked for me ?? Although it looks like it only works if the events were added in the same month when they should be displayed (which is the case on my site, so it worked) – maybe try changing also the db query to use custom dates? So on line 168 you’d change

    $args = array ('scope'=>array($_REQUEST['start'], $_REQUEST['end']), 'owner'=>false, 'status'=>1, 'order'=>'ASC', 'orderby'=>'post_date','full'=>1);

    with something like this

    $args = array ('owner'=>false, 'status'=>1, 'order'=>'ASC', 'meta_key'=> 'event_date', 'orderby'=> 'meta_value','full'=>1,'meta_query' => array(array('key' => 'event_date', 'value' => $_REQUEST['start'],'compare' => '>='), array('key' => 'event_date', 'value' => $_REQUEST['end'], 'compare' => '<=')));

    if this doesn’t work, I’m afraid I don’t have other ideas ??

    • This reply was modified 1 year, 7 months ago by moocker.

    Hi, @moocker! Thank you soooo much for your help. I’ll play around with the codes you provided in your answers. I now have new paths to explore to get it done, and I couldn’t ask for more. Your answers are the furthest I’ve gone with this, and there’s very little information out there. I feel I’m almost there!!!

    And most of all, thank you again for representing what the WordPress community -in fact, any community- should be: people helping each other. ??????

    • This reply was modified 1 year, 7 months ago by codimex. Reason: Tagging the user
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show future posts via custom DateField?’ is closed to new replies.