<p>I think I worked this out. It looks like the related entries need to be contained in the user loop. This is what I used to make this work:</p>

<pre><code>{% set categoryUsers = craft.users.relatedTo(category) %}
    {% paginate categoryUsers.limit(1) as entries %}

        {% for categoryUser in entries %}
            {{ categoryUser.username }}

            {% set categoryEntry = craft.entries.section('jobs').authorId(categoryUser.id).first() %}       
                {% if categoryEntry %}
                    {{ categoryEntry.positionTitle }} (And other fields not added yet.)
                {% endif %}

             &lt;p&gt;Testing the total found: {{ categoryUsers|length }}&lt;/p&gt;
        {% endfor %}

    {% if paginate.prevUrl %}&lt;a href="{{ paginate.prevUrl }}" class="pagination left"&gt;&amp;laquo; Previous Page&lt;/a&gt;{% endif %}
    {% if paginate.nextUrl %}&lt;a href="{{ paginate.nextUrl }}" class="pagination right"&gt;Next Page &amp;raquo;&lt;/a&gt;{% endif %}

    {% endpaginate %}
</code></pre>

<p>Still testing, but I think this is the solution. (Unless someone else has a better way of doing this. :)) </p>

CC BY-SA 3.0
2014-10-10T22:34:49.040Z
2014-10-10T22:34:49.040Z
Angela
<p>This is a category page. I am trying to display all entries from users with this specific category selected in their account (user field that is a category field type.) This is the code I have so far, but it is not returning results. No errors - just not returning anything unfortunately:</p>

<pre><code>&lt;h1&gt;{{ category.title }}&lt;/h1&gt;

{# Grab all the users who have this category selected (which is a 'category field type' user field) #}
{% set categoryUsers = craft.users.relatedTo(category).limit(null) %}

{# Grab all of the entries by those users #}    
{% set categoryUserEntries = craft.entries.section('jobs').relatedTo(categoryUsers).limit(null) %}

{% paginate categoryUserEntries.limit(8) as entries %}

     {% for entry in entries %} 
         &lt;h1&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h1&gt;
     {% endfor %}

     {% if paginate.prevUrl %}&lt;a href="{{ paginate.prevUrl }}" class="pagination left"&gt;&amp;laquo; Previous Page&lt;/a&gt;{% endif %}
     {% if paginate.nextUrl %}&lt;a href="{{ paginate.nextUrl }}" class="pagination right"&gt;Next Page &amp;raquo;&lt;/a&gt;{% endif %}

{% endpaginate %}
</code></pre>

<p>Thanks in advance!</p>

CC BY-SA 3.0
2014-10-09T17:48:01.370Z
Add a `{{ categoryUserEntries|length }}` before the pagination part. Does that return anything?
Brad Bell
CC BY-SA 3.0
2014-10-09T21:56:31.893Z
This returned '0' although it should return 1 because  1 user has this category selected in the category user field. Testing the first variable - {{ categoryUsers|length }} -  does give the correct amount so it looks like this is an issue with the way the 'relatedTo' is working for this.
Angela
<entries><relations><category>
Trying to list entries related to users with a specific category selected
# Trying to list entries related to users with a specific category selected

(Asked by: username_0 on 2014-10-09)

This is a category page. I am trying to display all entries from users with this specific category selected in their account (user field that is a category field type.) This is the code I have so far, but it is not returning results. No errors - just not returning anything unfortunately:
{{ category.title }}

{# Grab all the users who have this category selected (which is a 'category field type' user field) #}
{% set categoryUsers = craft.users.relatedTo(category).limit(null) %}

{# Grab all of the entries by those users #}    
{% set categoryUserEntries = craft.entries.section('jobs').relatedTo(categoryUsers).limit(null) %}

{% paginate categoryUserEntries.limit(8) as entries %}

     {% for entry in entries %} 
         {{ entry.title }}
     {% endfor %}

     {% if paginate.prevUrl %}« Previous Page{% endif %}
     {% if paginate.nextUrl %}Next Page »{% endif %}

{% endpaginate %}

Thanks in advance!

**Tags:** entries, relations, category
> **Comments:**
> **username_1**: Add a `{{ categoryUserEntries|length }}` before the pagination part. Does that return anything?  
> **username_0**: This returned '0' although it should return 1 because  1 user has this category selected in the category user field. Testing the first variable - {{ categoryUsers|length }} -  does give the correct amount so it looks like this is an issue with the way the 'relatedTo' is working for this.  

---

## 1 answers

### Answer by username_0 on 2014-10-10. Score: 1

I think I worked this out. It looks like the related entries need to be contained in the user loop. This is what I used to make this work:
{% set categoryUsers = craft.users.relatedTo(category) %}
    {% paginate categoryUsers.limit(1) as entries %}

        {% for categoryUser in entries %}
            {{ categoryUser.username }}

            {% set categoryEntry = craft.entries.section('jobs').authorId(categoryUser.id).first() %}       
                {% if categoryEntry %}
                    {{ categoryEntry.positionTitle }} (And other fields not added yet.)
                {% endif %}

             Testing the total found: {{ categoryUsers|length }}
        {% endfor %}

    {% if paginate.prevUrl %}« Previous Page{% endif %}
    {% if paginate.nextUrl %}Next Page »{% endif %}

    {% endpaginate %}

Still testing, but I think this is the solution. (Unless someone else has a better way of doing this. :))


---

