Answers.Body: <p>I forgot about the related entries.  So, I actually want to pull the related <code>countries</code> from the <code>**entries**</code> related to the <code>market</code>.</p>
  
  <p>Here is the solution.  <a href="https://craftcms.stackexchange.com/questions/15257/show-all-tags-related-to-a-category">The key was the answer to this related question about related tags.</a></p>
  
  <p><code>{% set entries = craft.entries.relatedTo(category).find() %}</code>
  <code>{% set nation = craft.categories.group('country').relatedTo(entries).find()%}</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-01T14:44:44.333Z
Answers.LastActivityDate: 2017-03-01T14:44:44.333Z
Answers.LastEditDate: 2017-04-13T12:51:00.160Z
Answers.UserDisplayName: Hellyar
Answers.Body: <p>Try changing </p>
  
  <pre><code>{% set name = craft.categories.group('country').relatedTo(category) %}
  </code></pre>
  
  <p>to</p>
  
  <pre><code>{% set name = craft.categories.group('country').relatedTo(category.slug) %}
  </code></pre>
  
  <p>Use the slug parameter to target a specific category in the category group. More parameters can be found here: <a href="https://craftcms.com/docs/templating/craft.categories" rel="nofollow noreferrer">https://craftcms.com/docs/templating/craft.categories</a></p>
  
  <pre><code>{% set category = craft.categories
      .group('nameOfCategoryGroup')
      .slug('specificCategoryInGroup')
      .limit(1)
      .first()
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-27T20:58:53.657Z
Answers.Text: I am still very much a novice.  I literally tried it with (category.slug) and then with (category.market).   I got nothing - no errors and no buttons.
Answers.UserDisplayName: Hellyar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T03:22:23.570Z
Answers.Text: Is the category an actual category object? I updated my answer that shows you how to get a category by its slug.
Answers.UserDisplayName: Brad
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T19:27:28.117Z
Answers.Text: I am not trying to pull a category. I want to pull related categories from a second category group
  
  I have 2 `category groups`   Group 1 = `markets`  Group 2 = `countries`.
  
  I have an entry index for each `market` that appears in `markets` (`Group 1`).  I then loop through each `descendant` of a given `market` to create filter buttons.
  
  
  Next, I want to pull the related `Group 2` `countries` associated with the given `Group 1` `market' -- 1 to many.  
  
  So, looking across all the entries in the index associated with the `Group 1` `market` what `countries` from `Group 2` are related.
Answers.UserDisplayName: Hellyar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-27T20:40:43.850Z
Answers.LastActivityDate: 2017-02-28T03:24:42.370Z
Answers.LastEditDate: 2017-02-28T03:24:42.370Z
Answers.UserDisplayName: Brad
Body: <p>`I will try this again.</p>
  
  <p>I have an index page for each category within category group 1 (<code>markets</code>).   </p>
  
  <p>I loop through the descendants of the given category to create filter buttons.</p>
  
  <p>How do i pull all the categories from a 2nd category group (<code>country</code>) assigned to each <code>market</code> from <code>markets</code>  - listing them only once </p>
  
  <p>For the <code>market</code> from category group-1 (<code>markets</code>), I am using:</p>
  
  <p><code>{% set segments = craft.categories.descendantOf(category) %}</code>
  <code>{% for category in segments %}</code>
  <code>button html using {{ category.title }}
  ``{% endfor %}</code></p>
  
  <p>For the <code>countries</code> from category group-2 (<code>country</code>), I tried using:</p>
  
  <p><code>{% set name = craft.categories.group('country').relatedTo(category) %}</code>
  <code>{% for nation in name %}</code> <code>button html with {{ nation.countryName }}</code>
  <code>{% endear %}</code></p>
  
  <p>Where <code>countryName</code> is the field name for the <code>country</code> group.</p>
  
  <p>I did not get a template error.  But nothing printed.  </p>
  
Tags: <templating>
Title: How do I pull categories from another category group for members of another category?
ThreadText: # How do I pull categories from another category group for members of another category?
  
  (Asked by: username_0 on 2017-02-27)
  
  `I will try this again.
  
  I have an index page for each category within category group 1 (`markets`).
  
  I loop through the descendants of the given category to create filter buttons.
  
  How do i pull all the categories from a 2nd category group (`country`) assigned to each `market` from `markets` - listing them only once
  
  For the `market` from category group-1 (`markets`), I am using:
  
  `{% set segments = craft.categories.descendantOf(category) %}`
  `{% for category in segments %}`
  `button html using {{ category.title }}
  ``{% endfor %}`
  
  For the `countries` from category group-2 (`country`), I tried using:
  
  `{% set name = craft.categories.group('country').relatedTo(category) %}`
  `{% for nation in name %}` `button html with {{ nation.countryName }}`
  `{% endear %}`
  
  Where `countryName` is the field name for the `country` group.
  
  I did not get a template error. But nothing printed.
  
  **Tags:** templating
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-03-01. Score: 1 | Accepted answer
  
  I forgot about the related entries. So, I actually want to pull the related `countries` from the `**entries**` related to the `market`.
  
  Here is the solution. [The key was the answer to this related question about related tags.](https://craftcms.stackexchange.com/questions/15257/show-all-tags-related-to-a-category)
  
  `{% set entries = craft.entries.relatedTo(category).find() %}`
  `{% set nation = craft.categories.group('country').relatedTo(entries).find()%}`
  
  
  ---
  
  ### Answer by username_1 on 2017-02-27. Score: 0
  
  Try changing
  
  ```
  {% set name = craft.categories.group('country').relatedTo(category) %}
  
  ```
  
  to
  
  ```
  {% set name = craft.categories.group('country').relatedTo(category.slug) %}
  
  ```
  
  Use the slug parameter to target a specific category in the category group. More parameters can be found here: <https://craftcms.com/docs/templating/craft.categories>
  
  ```
  {% set category = craft.categories
      .group('nameOfCategoryGroup')
      .slug('specificCategoryInGroup')
      .limit(1)
      .first()
  %}
  
  ```
  
  > **Comments:**
  > **username_0**: I am still very much a novice.  I literally tried it with (category.slug) and then with (category.market).   I got nothing - no errors and no buttons.  
  > **username_1**: Is the category an actual category object? I updated my answer that shows you how to get a category by its slug.  
  > **username_0**: I am not trying to pull a category. I want to pull related categories from a second category group  I have 2 `category groups`   Group 1 = `markets`  Group 2 = `countries`.  I have an entry index for each `market` that appears in `markets` (`Group 1`).  I then loop through each `descendant` of a given `market` to create filter buttons.   Next, I want to pull the related `Group 2` `countries` associated with the given `Group 1` `market' -- 1 to many.    So, looking across all the entries in the index associated with the `Group 1` `market` what `countries` from `Group 2` are related.  
  
  ---
  
  