Answers.Body: <p>This should work:</p>
  
  <pre><code>$section = craft()-&gt;sections-&gt;getSectionByHandle('sectionHandle');
  $sectionId = section-&gt;id;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-05T11:37:48.093Z
Answers.Text: what about categories? craft()->categories->getCategoryByHandle('handle'); is not working.
Answers.UserDisplayName: ladrua
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-26T12:18:33.950Z
Answers.LastActivityDate: 2016-01-26T12:18:33.950Z
Answers.UserDisplayName: carlcs
Body: <p>What would be the best way of finding a <code>sectionId</code> by its slug within my plugin?</p>
  
Tags: <plugin-development><sections>
Title: Best way to find sectionId by slug
ThreadText: # Best way to find sectionId by slug
  
  (Asked by: username_0 on 2016-01-26)
  
  What would be the best way of finding a `sectionId` by its slug within my plugin?
  
  **Tags:** plugin-development, sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-26. Score: 6 | Accepted answer
  
  This should work:
  
  ```
  $section = craft()->sections->getSectionByHandle('sectionHandle');
  $sectionId = section->id;
  
  ```
  
  > **Comments:**
  > **username_0**: what about categories? craft()->categories->getCategoryByHandle('handle'); is not working.  
  
  ---
  
  