Okay
  Public Ticket #3751648
Adding custom url
Open

Comments

  •  2
    feriamsidera started the conversation

    Is there an easy code I can add to my functions.php to add a custom URL section that only shows if valorized with a value to an external ticket system? I need two links for some of their exhibits. I know i could just hard code it in the description and I tried to add something with with ACF but ACF doesn't recognize STEC. Ideally it would be on the introduction page. 

  •  866
    Zhivko replied

    Hi,

    You could filter the items before return and attach the extra content if certain condition is met like this:

    add_filter('stec_event_controller_get_items', function($data, $request) {
    
        $events = $data->get_data();
    
        $context = $request->get_param('context');
    
        // Modify only if data is for the front-end
        if ($context !== 'event') {
            return $data;
        }
    
        foreach ($events as $k => $event) {
    
            $condition_is_met = true;
    
            if ($condition_is_met) {
    
                $extra_description_content = 'MY EXTRA CONTENT';
    
                $events[$k]['description'] .= $extra_description_content;
    
            }
    
        }
    
        $data->set_data($events);
    
        return $data;
    
    }, 10, 2);

    Stachethemes Developer

  •  866
    Zhivko replied

    Similarly for the event single page. The calendar has following filter:

      $item = apply_filters('stec_event_controller_get_item', $item, $request);

    Stachethemes Developer

  •  2
    feriamsidera replied

    Zhivko, 

    I've tried this on a staging site. How do I actually add a new custom field for events with another url link to the introduction page. Is there anyway to reveal "events" as a post type in Advanced Custom Fields and then use your provided script below to show those fields if present?