I want to delete all data in one channel. And I found that, the best way to delete all entry in channel is delete this channel and re-create it follow this article: What is the best way to delete every entry in a channel?

and I tried to delete channel follow this article: http://ellislab.com/expressionengine/user-guide/development/api/api_channel_structure.html

I know that the site_id is 1 and the channel_id of channel I need to delete is 1. But when I tried these code:

ee()->load->library('api'); ee()->api->instantiate('channel_structure');
$channel_id = 1;$site_id = 1;
ee()->api_channel_structure->delete_channel((int) $channel_id, [(int) $site_id]);

I got this error:

Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/au/admin/expressionengine/libraries/Functions.php(679) : eval()'d code on line 7

I tried with:

ee()->api_channel_structure->delete_channel((int) 1, [(int) 1]);
ee()->api_channel_structure->delete_channel(1, 1);

But got same issue.

Does somebody know how to solve this issue. Thank so much!

1 Answer 1


If your preferred method to delete all the entries for a given channel is to just delete the channel, then you do not need to use the Channel API. You can just delete the channel in the control panel. Go to Admin > Channels and click "Delete" next to the channel you want to remove.

If instead you prefer to do it using the API, then there is an error in your code that needs to be fixed to begin with. The documentation uses square brackets to indicate arguments that are optional.

So where the documentation for delete_channel says...

ee()->api_channel_structure->delete_channel((int) $channel_id, [(int) $site_id]);

...the second argument for site_id is optional. If you actually use that argument you should not include the brackets.

You would just do:

ee()->api_channel_structure->delete_channel(1, 1);

You could even just leave the site_id argument out, since it is optional.

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.