Answers.Body: <p>All you need to do is this in the <code>product</code> for Loop</p>
  
  <pre><code>{% if product.category.first.slug == 'brandx' %}
      Brand X
  {% endif %}
  </code></pre>
  
  <p>Or Shorthand </p>
  
  <pre><code>{{ product.category.first.slug == 'brandx' ? 'Brand X' }}  
  </code></pre>
  
  <p>Not tested but thats the gist of it.</p>
  
  <p>--Edited  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-16T18:07:16.607Z
Answers.Text: This is nice and tidy, but will not work if you have set multiple categories before `brandx`.
  
  I have used:
  
      {% set isBrandx = false %}
      {% for item in product.category %}
          {% if product.slug == 'brandx' %}
              {% set isBrandx = true %}
          {% endif %}
      {% endfor %}
  
  I can then test against `isBrandx` wherever I want. Open to suggestions, however!
Answers.UserDisplayName: ianp
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-17T03:35:43.367Z
Answers.Text: Yep works with a couple of formatting edits. This solution is particularly annoying since my first gut was to just pull from the category field, but I didn't include the 'first'. I'm still unclear when 'first' is needed (time to research).
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-17T04:08:23.897Z
Answers.Text: `first` is needed whenever the default returns an array (or an array-like object), you know there is only one, or you only want the first one. I.e. an assets, category, entries, or users field for example that you have set a limit of 1.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-17T00:44:12.330Z
Answers.LastActivityDate: 2014-12-17T07:32:23.267Z
Answers.LastEditDate: 2014-12-17T07:32:23.267Z
Answers.UserDisplayName: Seán O'Grady
Body: <p>I have succussfully been able to list entries within the 'brandx' category slug, but I can't figure out a way to print specific content <strong>only if</strong> the current 'product' listing is related to the 'brandx' category.</p>
  
  <p>I have tried quite a few things and have come up empty, so I feel like I'm either missing something basic, or there's a trick I can't find in the docs or here.</p>
  
  <pre><code>{% paginate craft.entries.section('shopDetails').level(1).limit(24) as postsOnPage %} 
        {% for product in postsOnPage %}
             …
              &lt;h5&gt;
                {% set cat = craft.categories.slug('brandx').first() %}
                {% set catGroup = craft.entries.relatedTo( cat ) %}
                {% if product {# is within the catGroup #}  %}
                Brand X
                {% endif %}
                {{ product.title }}
              &lt;/h5&gt;
  {% endpaginate %}
  </code></pre>
  
Tags: <categories><relations>
Title: If Entry is related to Category-A, then print xyz
ThreadText: # If Entry is related to Category-A, then print xyz
  
  (Asked by: username_0 on 2014-12-16)
  
  I have succussfully been able to list entries within the 'brandx' category slug, but I can't figure out a way to print specific content **only if** the current 'product' listing is related to the 'brandx' category.
  
  I have tried quite a few things and have come up empty, so I feel like I'm either missing something basic, or there's a trick I can't find in the docs or here.
  
  ```
  {% paginate craft.entries.section('shopDetails').level(1).limit(24) as postsOnPage %} 
        {% for product in postsOnPage %}
             …
              <h5>
                {% set cat = craft.categories.slug('brandx').first() %}
                {% set catGroup = craft.entries.relatedTo( cat ) %}
                {% if product {# is within the catGroup #}  %}
                Brand X
                {% endif %}
                {{ product.title }}
              </h5>
  {% endpaginate %}
  
  ```
  
  **Tags:** categories, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-17. Score: 2 | Accepted answer
  
  All you need to do is this in the `product` for Loop
  
  ```
  {% if product.category.first.slug == 'brandx' %}
      Brand X
  {% endif %}
  
  ```
  
  Or Shorthand
  
  ```
  {{ product.category.first.slug == 'brandx' ? 'Brand X' }}  
  
  ```
  
  Not tested but thats the gist of it.
  
  --Edited
  
  > **Comments:**
  > **username_0**: Yep works with a couple of formatting edits. This solution is particularly annoying since my first gut was to just pull from the category field, but I didn't include the 'first'. I'm still unclear when 'first' is needed (time to research).  
  > **username_3**: `first` is needed whenever the default returns an array (or an array-like object), you know there is only one, or you only want the first one. I.e. an assets, category, entries, or users field for example that you have set a limit of 1.  
  > **username_2**: This is nice and tidy, but will not work if you have set multiple categories before `brandx`.  I have used:      {% set isBrandx = false %}     {% for item in product.category %}         {% if product.slug == 'brandx' %}             {% set isBrandx = true %}         {% endif %}     {% endfor %}  I can then test against `isBrandx` wherever I want. Open to suggestions, however!  
  
  ---
  
  