~franz/f-a.nz

ref: e52c0c035c5cd51a128c386bbceae82c1d1a3cd6 f-a.nz/_dev/2015/2015-03-11-expressionengine-categories-loop-filter-by-group-id-and-category-id.markdown -rw-r--r-- 779 bytes
e52c0c03 — Franz Geffke Commit local copy 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
layout: post
title:  "ExpressionEngine categories loop: Filter by group_id and category_id"
date:   2015-03-11 08:00:00
excerpt: "Only show catgories in category_group 2 and exclude category with category_id 68"
categories: ExpressionEngine
version: 2.9.1
packages: ExpressionEngine
source:
sourcetitle:
---

In this example, we would like to achieve two things:

1. Only show categories in category_group 2
2. Exclude the category with category_id 68

```<div class="form-group">
  <label for="title">Categories</label>
  <select name="category[]" id="categories">
    {categories show_group="2"}
      {if {category_id} != 68}
        <option value="{category_id}"{selected}>
          {category_name}
        </option>
      {/if}
    {/categories}
  </select>
</div>
```