2

Is it possible to add entries into categories when creating them with the Channel Entries API cant see anything in the documentation.

1 Answer 1

4

Within the channel entry API, you can pass the data array containing the array of category ids like:

ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');

$data = array(
    'title'         => 'ENTRY TITLE',
    'entry_date'    => time(),
    'channel_id'    => x,
    'category'      => array($category_id)
);

ee()->api_channel_fields->setup_entry_settings($channel_id, $data);

ee()->api_channel_entries->submit_new_entry($channel_id, $data);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.