• Resolved alfkoblischke

    (@alfkoblischke)


    This code works – except for the category. I have an existing event-category (…wp-admin/term.php?taxonomy=tribe_events_cat&tag_ID=4&post_type…)

    $args = [
            'title'             => 'Cool Event with Cost',
            'description'       => 'This is showing that the description can be a long string and...',
            'start_date'        => date( 'Y-m-d H:i:s' ),
            'end_date'          => date( 'Y-m-d H:i:s', strtotime( '+2 hours' ) ),
            'url'               => 'https://example-external-website.com',
            'cost'              => 15,
            'currency_symbol'   => '€',
            'currency_position' => 'prefix',
            'status'            => 'publish',
            'category'          => [ 4 ],
        ];
    
        $result = tribe_events()->set_args( $args )->create();

    My amount of grey hair is increassing ;). Can anybody help?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support sdokus

    (@sdokus)

    Hi there! I just double-checked the code from this documentation (https://docs.theeventscalendar.com/apis/orm/create/events/examples/#event-with-an-existing-category) and the code you provided and both worked for me to create an event with an existing category using the ORM.

    Can you please give us some more information about how you’re recreating the issue? A step-by-step process would be helpful, especially including more information about how the existing category is set up.

    Thread Starter alfkoblischke

    (@alfkoblischke)

    I have just the piece of code in function and it creates the event but does not add the exisiting category. The category was created via die WP-Admin – >Events – > Event-Categories

    Plugin Support sdokus

    (@sdokus)

    That is strange for sure! Just to try out the different options for that argument, can you please try switching from an integer to a string? It should accept both, but could be worth testing just to cover the bases. So that line would look like this instead:

    'category' => [ '4' ]

    Thread Starter alfkoblischke

    (@alfkoblischke)

    Hi sdokus,

    does nor work either. array(4) and array (‘4’) also dont work. Is it possible that it only works in the “pro” version?
    Best regards
    Alf

    Plugin Support sdokus

    (@sdokus)

    Hey Alf,

    Bummer, thanks for giving that a try!

    I tested the code again with The Events Calendar as the only active plugin on the whole site and it still worked, so this might be caused by something specific to your site.

    Could you try adding a new category and testing the code again with that new category ID? That way we can determine if the issue is coming from the specific category or not.

    Thread Starter alfkoblischke

    (@alfkoblischke)

    Hi sdokus,
    thank you very much for your quick reply. But it still does not work.

    • Created new Event Category: Nothing changed. The Event Category still does not show.
    • Deactivad all plugins, except for the Events Calendar and my aditional plugin to add the event: Category still does not show

    Best regards
    Alf

    Plugin Support Darian

    (@d0153)

    Hi @alfkoblischke

    Thank you for your message. Let me share this with the team and I’ll make sure to update you once we have more information.

    In the meantime, let us know if you have other questions or concerns.

    Plugin Support Darian

    (@d0153)

    Hi @alfkoblischke

    Thank you for your patience.

    After conducting further testing on the code that you provided, I was able to successfully make it work. For my test, I inserted the code snippet into the header file of the theme.

    I am curious to know how you implemented the custom code. Could you please share more details about the process you followed?

    Plugin Support Darian

    (@d0153)

    Hi there,

    It seems like it has been some time since we received a response from you, therefore, I will consider this matter as resolved. If you require any further assistance, please do not hesitate to start a new thread.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘I cannot add an event category’ is closed to new replies.