• Resolved dadadmin

    (@dadadmin)


    I would like to be able to attach pdfs to my events. I am already using ACF throughout my site. I added the Field titled more_details to my ACF and attached it to events. I have tried calling #_ATT{more_details} and that only outputs the attachment id.

    I have tried using this following code, where I define and get the value of the ACF before calling the event, and that doesn’t work either. Any ideas how I can get this to work>

    global $EM_Event;
    /* @var $EM_Event EM_Event */
    
    $file = get_field('more_details');
    
    echo EM_Events::output(array('format'=>
    '
    <div id="eventlist">
    #_EVENTIMAGE
    <h3>#_ATT{sub_headline}</h3>
    <a href="'.$file.'">MORE DETAILS</a>
    </div>
    
    ',
    'category'=>36)); ?>

    https://www.ads-software.com/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    sorry Im afraid that this is not possible at the moment and it might need custom coding on your part to make this work.

    Thread Starter dadadmin

    (@dadadmin)

    The ACF support told me this

    If the events are just a custom post type and you can get the ID of the event, you can pass it to the second parameter of get_field() like this:

    $event_id = 99; // change this with the ID of the event
    $file = get_field('more_details', $event_id);
    echo $file;

    Where 99 is the ID of the event.

    I’d like to use this in a list though. How do I get $event_id to equal an event id of the query, not a specific event?

    Thread Starter dadadmin

    (@dadadmin)

    I rewrote my code and got it to work. I know there have been some other people in the past who had the same issue, so its a an easy way to attach a file to an event using ACF File Field

    <?php
                $events = EM_Events::get(array('category'=>'36'));
                foreach( $events as $EM_Event ){
                    $event_id = $EM_Event->output("#_EVENTPOSTID");
    
           // change this with the ID of the event
    $file = get_field('more_details', $event_id);
    
     ?>   
    
    <div id="eventlist">
    <?php echo $EM_Event->output("#_EVENTIMAGE");?>
    <h3><?php echo $EM_Event->output("#_ATT{sub_headline}");?></h3>
    <a href="<?php echo $file;?>">MORE DETAILS</a>
    </div>
    
      <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Advanced Custom Fields File with Events Manager’ is closed to new replies.