Answers.Body: <p>The field in the output from getCompleteInfo() is &quot;event_type&quot; not &quot;event_type_id&quot;, but note that <code>CRM_Event_BAO_Event::getCompleteInfo()</code> is an internal function that just happens to be available, so you might prefer to use the api:</p>
  <pre><code>$eventList = \Civi\Api4\Event::get()-&gt;addSelect('*', 'event_type_id:label')-&gt;execute();
  foreach ($eventList as $event) {
    $typeLabel = $event['event_type_id:label'];
  }
  </code></pre>
  <p>It's also easier to discover what fields are available with the api, using the Support - Developer menu in civi.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-30T12:47:32.857Z
Answers.Text: Thank you for this. I was having a difficult time finding documentation, but I realize now I was looking for the wrong thing. Time to update my code!
Answers.UserDisplayName: Paul Dufresne
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-30T05:37:38.390Z
Answers.LastActivityDate: 2023-01-30T05:37:38.390Z
Answers.UserDisplayName: Demerit
Body: <p>I'm writing a WordPress plugin to display a list of CiviCRM Events, but I'm having a difficult time figuring out how to obtain the label for the event type. I can retrieve the list of events, and the <code>event_type_id</code>, but I haven't figured out how to retrieve the label for the event type.</p>
  <pre><code>    $eventList = CRM_Event_BAO_Event::getCompleteInfo();
  
      foreach ( $eventList as $event ) {
          // Upon further testing, the following returns a blank
          $type = CRM_Utils_Array::value( 'event_type_id', $event );
  
          $typeLabel = // This is where it falls apart...
  
      }
  </code></pre>
  
Tags: <wordpress><civievent><api><plugin>
Title: Access event type details with query from wordpress
ThreadText: # Access event type details with query from wordpress
  
  (Asked by: username_0 on 2023-01-30)
  
  I'm writing a WordPress plugin to display a list of CiviCRM Events, but I'm having a difficult time figuring out how to obtain the label for the event type. I can retrieve the list of events, and the event_type_id, but I haven't figured out how to retrieve the label for the event type.
      $eventList = CRM_Event_BAO_Event::getCompleteInfo();
  
      foreach ( $eventList as $event ) {
          // Upon further testing, the following returns a blank
          $type = CRM_Utils_Array::value( 'event_type_id', $event );
  
          $typeLabel = // This is where it falls apart...
  
      }
  
  **Tags:** wordpress, civievent, api, plugin
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-30. Score: 1 | Accepted answer
  
  The field in the output from getCompleteInfo() is "event_type" not "event_type_id", but note that CRM_Event_BAO_Event::getCompleteInfo() is an internal function that just happens to be available, so you might prefer to use the api:
  $eventList = \Civi\Api4\Event::get()->addSelect('*', 'event_type_id:label')->execute();
  foreach ($eventList as $event) {
    $typeLabel = $event['event_type_id:label'];
  }
  
  It's also easier to discover what fields are available with the api, using the Support - Developer menu in civi.
  
  > **Comments:**
  > **username_0**: Thank you for this. I was having a difficult time finding documentation, but I realize now I was looking for the wrong thing. Time to update my code!  
  
  ---
  
  