<p>I'm currently trying to get all entries which belong to a section which is related to that category. e.g.</p>

<ul>
<li>Category

<ul>
<li>Brand

<ul>
<li>Offer</li>
</ul></li>
</ul></li>
</ul>

<p>Offer belongs to a brand.</p>

<p>Brand has a category field.</p>

<pre><code>{% set entries = craft.entries.section('offers').relatedTo(category).find() %}
</code></pre>

<p>Currently trying the above, but returns nothing.</p>

<p>Thanks</p>

<p>-- EDIT --</p>

<p>The offer entries belong to a brand, a brand section belongs to a category. I'm trying to fetch all offers of all the brands which belong to a category.</p>

CC BY-SA 3.0
2018-03-17T16:16:09.287Z
Your code works for me. Did you make sure you fetched the correct category and your category field is not inside a matrix?
Robin Schambach
CC BY-SA 3.0
2018-03-17T16:47:50.297Z
Doesn't work for me, the code works but it doesn't return anything. The Section is correct. This is being called on the category page itself.
JMKelley
CC BY-SA 3.0
2018-03-17T17:15:00.487Z
yeah but is your relation field in a matrix? because you can't revert search related entries inside matrix elements
Robin Schambach
CC BY-SA 3.0
2018-03-18T02:20:38.510Z
Is this an entry where you have a category field & you are trying to display a button with the brand link and name of that category. Or is this a category and you want to show all entries related to it?
mateostabio
CC BY-SA 3.0
2018-03-18T12:41:25.037Z
Edited the question. They are not in a matrix.
JMKelley
CC BY-SA 3.0
2018-03-18T13:11:40.360Z
There is no default way to connect a section with a category. Did you create a custom field in your category that links to a section? You can only relate elements with each other and sections are no elements. Maybe your structure does not really fit to the mechanics in Craft or I am not able to understand your explanation.
Robin Schambach
CC BY-SA 3.0
2018-03-18T21:21:32.373Z
Check what the value of `category` is: `{% dump(category) %}`. Check that without the `relatedTo` you get all the entries: `{% dump(craft.entries.section('offers').find()) %}` Maybe that will give you a clue to what is going wrong.
Marion Newlevant
<entries><categories><sections>
Get Entries from Section related to a category
# Get Entries from Section related to a category

(Asked by: username_0 on 2018-03-17)

I'm currently trying to get all entries which belong to a section which is related to that category. e.g.

Category


Brand


Offer



Offer belongs to a brand.
Brand has a category field.
{% set entries = craft.entries.section('offers').relatedTo(category).find() %}

Currently trying the above, but returns nothing.
Thanks
-- EDIT --
The offer entries belong to a brand, a brand section belongs to a category. I'm trying to fetch all offers of all the brands which belong to a category.

**Tags:** entries, categories, sections

> **Comments:**
> **username_1**: Your code works for me. Did you make sure you fetched the correct category and your category field is not inside a matrix?  
> **username_0**: Doesn't work for me, the code works but it doesn't return anything. The Section is correct. This is being called on the category page itself.  
> **username_1**: yeah but is your relation field in a matrix? because you can't revert search related entries inside matrix elements  
> **username_2**: Is this an entry where you have a category field & you are trying to display a button with the brand link and name of that category. Or is this a category and you want to show all entries related to it?  
> **username_0**: Edited the question. They are not in a matrix.  
> **username_1**: There is no default way to connect a section with a category. Did you create a custom field in your category that links to a section? You can only relate elements with each other and sections are no elements. Maybe your structure does not really fit to the mechanics in Craft or I am not able to understand your explanation.  
> **username_3**: Check what the value of `category` is: `{% dump(category) %}`. Check that without the `relatedTo` you get all the entries: `{% dump(craft.entries.section('offers').find()) %}` Maybe that will give you a clue to what is going wrong.  

---

## 0 answers

