<p>Not with the out-of-the-box field types. You could create a field type that is category+default. The <a href="https://github.com/marionnewlevant/craft-defaultcolor">Default Color</a> plugin might be a good place to start.</p>

CC BY-SA 3.0
2014-07-31T17:17:55.547Z
2014-07-31T17:17:55.547Z
Marion Newlevant
<p>You could output the categories in a way that makes them look like they are from a specific category when they don't have any categories assigned to them.</p>

<p>When you're outputting any of the entries, just add a custom link if there isn't a category assigned:</p>



<pre class="lang-twig prettyprint-override"><code>{% if entry.categories|length %}
    {% for category in entry.categories %}
        &lt;a href="/blog/category/{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
    {% endfor %}
{% else %}
    &lt;a href="/blog/category/default-category-slug"&gt;Default Category Title&lt;/a&gt;
{% endif %}
</code></pre>

<p>Create a route that points "/blog/category/default-category-slug" to your filtered listing template (/blog/index, /blog/category etc.).</p>

<p>On the filtered listing template check if the default category slug is in the URL:</p>

<pre class="lang-twig prettyprint-override"><code>{% if craft.request.getSegment(3) == 'default-category-slug' %}
</code></pre>

<p>If that evaluates to true, you can now get the entries without any categories assigned to them and loop through them, see this question: <a href="https://craftcms.stackexchange.com/questions/603/how-to-find-entries-with-no-category">How to find entries with no category</a>:</p>

<pre class="lang-twig prettyprint-override"><code>{% set uncategorized = craft.entries.section('blog').search('-categories:*') %}
{% for entry in uncategorized %}
    {# show entry #}
{% endfor %}
</code></pre>

<hr>

<p>Any other times you need to get the entries that "have" the default category, to loop through them, use <a href="http://buildwithcraft.com/docs/relations" rel="nofollow noreferrer"><code>.relatedTo</code></a> on etc., instead of using:</p>

<pre class="lang-twig prettyprint-override"><code>{% set entriesWithDefaultCategory = craft.entries.section('blog').relatedTo('the-default-category') %}
</code></pre>

<p>Use this like on the filtered listing above:</p>

<pre class="lang-twig prettyprint-override"><code>{% set uncategorized = craft.entries.section('blog').search('-categories:*') %}
</code></pre>

CC BY-SA 3.0
2014-07-31T20:00:16.433Z
2014-07-31T20:00:16.433Z
2017-04-13T12:50:59.930Z
Simon Kuran
<p>I've set up a channel using categories to distinguish between different blog post types. The majority will probably be in one category, so it would be great to be able to specify a default category. However, as far as I can see the Category field type (unlike, say, the Drop Down field type) doesn't give you the option to set a default... Is there any way of doing this?</p>

<templating><categories><field>
Is there any way of specifying a default category for a category field?
# Is there any way of specifying a default category for a category field?

(Asked by: username_0 on 2014-07-30)

I've set up a channel using categories to distinguish between different blog post types. The majority will probably be in one category, so it would be great to be able to specify a default category. However, as far as I can see the Category field type (unlike, say, the Drop Down field type) doesn't give you the option to set a default... Is there any way of doing this?

**Tags:** templating, categories, field

---

## 2 answers

### Answer by username_2 on 2014-07-31. Score: 6 | Accepted answer

You could output the categories in a way that makes them look like they are from a specific category when they don't have any categories assigned to them.
When you're outputting any of the entries, just add a custom link if there isn't a category assigned:
{% if entry.categories|length %}
    {% for category in entry.categories %}
        {{ category.title }}
    {% endfor %}
{% else %}
    Default Category Title
{% endif %}

Create a route that points "/blog/category/default-category-slug" to your filtered listing template (/blog/index, /blog/category etc.).
On the filtered listing template check if the default category slug is in the URL:
{% if craft.request.getSegment(3) == 'default-category-slug' %}

If that evaluates to true, you can now get the entries without any categories assigned to them and loop through them, see this question: How to find entries with no category:
{% set uncategorized = craft.entries.section('blog').search('-categories:*') %}
{% for entry in uncategorized %}
    {# show entry #}
{% endfor %}


Any other times you need to get the entries that "have" the default category, to loop through them, use .relatedTo on etc., instead of using:
{% set entriesWithDefaultCategory = craft.entries.section('blog').relatedTo('the-default-category') %}

Use this like on the filtered listing above:
{% set uncategorized = craft.entries.section('blog').search('-categories:*') %}


---

### Answer by username_1 on 2014-07-31. Score: 5

Not with the out-of-the-box field types. You could create a field type that is category+default. The [Default Color](https://github.com/marionnewlevant/craft-defaultcolor) plugin might be a good place to start.


---

