• Resolved Jean R.

    (@efbi)


    Hi,
    
    I'm trying to create event programmatically with <code>wp_insert_post</code>. 
    While the event is correctly insert in database, and listed in my back, it doesn't show in the calendar ! 
    
    I also tried <code>tribe_create_event</code>, same thing.
    
    Did I missing something ? 
    I have to publish manually from the back to get my events displayed.

    A part of my code :

    $my_post = array(
            'ID'            => $ID,
            // 'post_type'     => TribeEvents::POSTTYPE,
            'post_type'     => "tribe_events",
            'post_title'    => wp_strip_all_tags($_POST['input_2']),
            'post_content'  => $_POST['input_21'],
            // 'post_status'   => $_POST['input_43'],
            'post_status'   => "publish",
            'post_author'   => get_current_user_id(),
            'meta_input'   => array(
                //Default to work well
                '_EventShowMapLink' => true,
                '_EventShowMap' => true,
                //others
                '_EventStartDate' => $_POST['input_11'] . " " . implode(":", $_POST['input_12']) . ":00",
                '_EventEndDate' => $_POST['input_13'] . " " . implode(":", $_POST['input_14']) . ":00",
                '_EventURL' => $_POST['input_28'],
                '_EventCost' => $_POST['input_27'],
                '_tribe_events_virtual_url' => $_POST['input_30']
            ),
            'tax_input'     => array(
                'tribe_events_cat' => array($_POST['input_8'])
            )
        );
    
        // $event_id = wp_insert_post($my_post);
        $event_id = tribe_create_event($my_post);
    • This topic was modified 3 years, 1 month ago by Jean R..
Viewing 1 replies (of 1 total)
  • Plugin Author Gustavo Bordoni

    (@bordoni)

    Hi sorry for such a long delay on my answer.

    And example of usage for creating events programmatically:

    $args     = [
    	'start_date' => '2020-08-07 09:00:00',
    	'end_date'   => '2020-08-07 11:00:00',
    	'timezone'   => 'America/New_York',
    	'title'      => 'Event Test',
    	'meta_input' => [ ],
    ];
    $event    = tribe_events()->set_args( $args )->create();
    
    

    Hopefully that solves your problem.
    Best Regards,

Viewing 1 replies (of 1 total)
  • The topic ‘wp_insert_post don’t show event in calendar’ is closed to new replies.