<p>This should work:</p>

<pre><code>$section = craft()-&gt;sections-&gt;getSectionByHandle('sectionHandle');
$sectionId = section-&gt;id;
</code></pre>

CC BY-SA 3.0
2016-02-05T11:37:48.093Z
what about categories? craft()->categories->getCategoryByHandle('handle'); is not working.
ladrua
CC BY-SA 3.0
2016-01-26T12:18:33.950Z
2016-01-26T12:18:33.950Z
carlcs
<p>What would be the best way of finding a <code>sectionId</code> by its slug within my plugin?</p>

<plugin-development><sections>
Best way to find sectionId by slug
# 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.  

---

