<p>Since <code>groundsQuestions</code> is a category field, calling it will return an element query on which you can call <code>one()</code>, <code>all()</code>, etc. </p>

<p>For example:</p>

<pre><code>$groundsQuestions = $entry-&gt;groundsQuestions-&gt;all();
</code></pre>

CC BY-SA 4.0
2018-05-30T17:21:18.127Z
2018-05-30T17:21:18.127Z
Ben Croker
<p>When I get an Entry Object that has been set, I notice all of my fields except the Category fields are available to me. For example:</p>

<pre><code>[_behaviors:yii\base\Component:private] =&gt; Array
    (
        [customFields] =&gt; craft\behaviors\ContentBehavior Object
            (
                [adjustedRemainingLife] =&gt; 100%
                [adjustedRemainingYears] =&gt; 116
                [answerSets] =&gt; [{"col3":"Paving and curbs are less than 3 years old, and in good condition. No repairs are needed, preventative maintenance ","col1":"Paving and curbs are in good condition, and only require routine maintenance - 90%","col2":"Minor repairs and patching are required, not exceeding 30% of value -\r\n60%","col4":"Significant repairs are needed to as much as 60% of value. - 30%","col5":"All or majority of systems should be replaced - 0%"}]
                [groundsQuestions] =&gt;
</code></pre>

<p>Where <code>groundsQuestions</code> is my category field, I figure if it isn't flowing through, there must be some way to get that value in a plugin?</p>

CC BY-SA 4.0
2018-05-30T05:20:36.123Z
It is exactly the same behavior as you already figured out here https://craftcms.stackexchange.com/questions/26326/get-the-related-entry-from-an-entries-field-in-a-matrix-block-within-a-plugin-cr
Robin Schambach
CC BY-SA 4.0
2018-05-30T06:19:22.350Z
Lightbulb moment!  Thanks @RobinSchambach!
Brett Moore
<plugin-development><plugins>
Is there a way to get categories relating to a specific entry within a plugin?
# Is there a way to get categories relating to a specific entry within a plugin?

(Asked by: username_0 on 2018-05-30)

When I get an Entry Object that has been set, I notice all of my fields except the Category fields are available to me. For example:
[_behaviors:yii\base\Component:private] => Array
    (
        [customFields] => craft\behaviors\ContentBehavior Object
            (
                [adjustedRemainingLife] => 100%
                [adjustedRemainingYears] => 116
                [answerSets] => [{"col3":"Paving and curbs are less than 3 years old, and in good condition. No repairs are needed, preventative maintenance ","col1":"Paving and curbs are in good condition, and only require routine maintenance - 90%","col2":"Minor repairs and patching are required, not exceeding 30% of value -\r\n60%","col4":"Significant repairs are needed to as much as 60% of value. - 30%","col5":"All or majority of systems should be replaced - 0%"}]
                [groundsQuestions] =>

Where groundsQuestions is my category field, I figure if it isn't flowing through, there must be some way to get that value in a plugin?

**Tags:** plugin-development, plugins
> **Comments:**
> **username_1**: It is exactly the same behavior as you already figured out here https://craftcms.stackexchange.com/questions/26326/get-the-related-entry-from-an-entries-field-in-a-matrix-block-within-a-plugin-cr  
> **username_0**: Lightbulb moment!  Thanks @RobinSchambach!  

---

## 1 answers

### Answer by username_2 on 2018-05-30. Score: 1

Since groundsQuestions is a category field, calling it will return an element query on which you can call one(), all(), etc. 
For example:
$groundsQuestions = $entry->groundsQuestions->all();


---

