Event Post Type

These functions can be used to manipulate Event data. These functions may be useful for integration with other WordPress plugins and extended functionality.

Create an Event

tribe_create_event(array $args)

$args accepts all the args that can be passed to wp_insert_post(). In addition to that, the following args can be passed specifically for the process of creating an Event:

  • EventStartDate date string (required) – Start date of the Event.
  • EventEndDate date string (required) – End date of the Event.
  • EventAllDay bool – Set to true if event has no start / end time and should run all day.
  • EventStartHour string – Event start hour (01 – 12).
  • EventStartMinute string – Event start minute (01 – 60).
  • EventStartMeridian string – Event start meridian (am or pm).
  • EventEndHour string – Event end hour (01 – 12).
  • EventEndMinute string – Event end minute (01 – 60).
  • EventEndMeridian string – Event end meridian (am or pm).
  • EventHideFromUpcoming bool – Set to true to hide this Event from the upcoming list view.
  • EventShowMapLink bool – Set to true to display a link to the map in the Event view.
  • EventShowMap bool – Set to true to embed the map in the Event view.
  • EventCost string – Default cost of the Event.
  • Venue array – Array of data to create or update an Venue to be associated with the Event. tribe_create_venue.
  • Organizer array – Array of data to create or update an Organizer to be associated with the Event. tribe_create_organizer.

Note: If ONLY the ‘VenueID’/'OrganizerID’ value is set in the ‘Venue’/'Organizer’ array, then the specified Venue/Organizer will be associated with this Event without attempting to edit the Venue/Organizer. If NO ‘VenueID’/'OrganizerID’ is passed, but other Venue/Organizer data is passed, then a new Venue/Organizer will be created.

Parameters

  • array
    $args: Elements that make up post to insert.

Returns

  • int

Examples

// Create post object
$my_post = array(
   'post_title' => 'My post',
   'post_content' => 'This is my post.',
   'post_status' => 'publish',
   'post_author' => 1,
   'EventStartDate' => '',
   'EventEndDate' => '',
   'EventStartHour' => '2',
   'EventStartMinute' => '29',
   'EventStartMeridian' => 'pm',
   'EventEndHour' => '4',
   'EventEndMinute' => '20',
   'EventEndMeridian' => 'pm',
   'Venue' => array(
 		'Venue' => 'Some Place',
 		'Country' => 'US',
 		'Address' => '1 W. Washington Ave.',
 		'City' => 'Madison',
 		'State' => 'WI'  	
   ),
   'Organizer' => array(
   	'Organizer' => 'Organizer Name',
   	'Email' => 'me@me.com'	
   )
);

// Insert the post into the database
tribe_create_event( $my_post );

More Info

Delete an Event

tribe_delete_event(int $postId, [bool $force_delete = false])

Parameters

  • int
    $postId: ID of the event to be deleted.
  • bool
    $force_delete: Whether to bypass trash and force deletion. Defaults to false.

Returns

  • bool

More Info

Update an Event

tribe_update_event(int $postId, array $args)

Parameters

  • int
    $postId: ID of the event to be modified.
  • array
    $args: Args for updating the post. See tribe_create_event() for more info.

Returns

  • int

More Info

Modern Tribe Newsletter

Insight, Discounts & Notices for People Who Kick Ass..