Answers.Body: <p>Because your <code>category</code> variable is no object of type <code>craft\elements\Category</code> but an <code>ElementQuery</code> in order to fetch the category you need to use the <code>one()</code> function</p>
  
  <pre class="lang-Twig prettyprint-override"><code>{% set category = craft.categories.slug(filter).one() %}  
  {% if category != null %}
      {{ category.titleTag }}
  {% endif %}
  </code></pre>
  
  <p>Your <code>{{category.titleTag}}</code> printed the search criteria. Imagine you would like to set other conditions in your query: how is Craft supposed to know when your query ends?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-25T14:16:12.987Z
Answers.LastActivityDate: 2018-09-25T14:46:06.327Z
Answers.LastEditDate: 2018-09-25T14:46:06.327Z
Answers.UserDisplayName: Robin Schambach
Body: <p>my categories have a custom field called <code>titleTag</code> for SEO as well as a number of other fields. When I render them at their URI (<code>/categories/cat1</code>) I can output those fields easily with <code>{{category.titleTag}}</code> etc. However on the main category page I also have a filter button that loads another URI via <code>jQuery.load()</code> to filter the items based on category. So in the filter template I have this to start.</p>
  
  <pre><code>{% set filter = craft.request.getParam('filter') %}
  {% set category = craft.categories.slug(filter) %}
  </code></pre>
  
  <p>I then want to output (amongst other things) the custom field values of the found category like so <code>{{category.titleTag}}</code> but it comes out null (the category found I am testing with has the field filled out.</p>
  
  <p>Where am I going wrong?</p>
  
Tags: <templating><categories><field>
Title: field from category not available via craft.categories
ThreadText: # field from category not available via craft.categories
  
  (Asked by: username_0 on 2018-09-25)
  
  my categories have a custom field called `titleTag` for SEO as well as a number of other fields. When I render them at their URI (`/categories/cat1`) I can output those fields easily with `{{category.titleTag}}` etc. However on the main category page I also have a filter button that loads another URI via `jQuery.load()` to filter the items based on category. So in the filter template I have this to start.
  
  ```
  {% set filter = craft.request.getParam('filter') %}
  {% set category = craft.categories.slug(filter) %}
  
  ```
  
  I then want to output (amongst other things) the custom field values of the found category like so `{{category.titleTag}}` but it comes out null (the category found I am testing with has the field filled out.
  
  Where am I going wrong?
  
  **Tags:** templating, categories, field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-25. Score: 0 | Accepted answer
  
  Because your `category` variable is no object of type `craft\elements\Category` but an `ElementQuery` in order to fetch the category you need to use the `one()` function
  
  ```Twig
  {% set category = craft.categories.slug(filter).one() %}  
  {% if category != null %}
      {{ category.titleTag }}
  {% endif %}
  
  ```
  
  Your `{{category.titleTag}}` printed the search criteria. Imagine you would like to set other conditions in your query: how is Craft supposed to know when your query ends?
  
  
  ---
  
  