What would be the best way of finding a sectionId by its slug within my plugin?

1 Answer 1


This should work:

$section = craft()->sections->getSectionByHandle('sectionHandle');
$sectionId = section->id;
  • what about categories? craft()->categories->getCategoryByHandle('handle'); is not working.
    – ladrua
    Feb 5, 2016 at 11:37

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.