Answers.Body: <p>I believe I have found the answer.</p>
  
  <pre><code>if(array_key_exists('byCategory', $filterAttributes))
  {
    foreach ($entry-&gt;getFieldLayout()-&gt;getFields() as $key) 
    {
        $field = $key-&gt;getField();
        if($field-&gt;type == "Categories"){
  
           if(!$this-&gt;addFilterdCategories($entry[$field-&gt;handle],$filterAttributes))
           {
               continue;
           }
        }
     }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-19T23:57:53.290Z
Answers.LastActivityDate: 2015-01-19T23:57:53.290Z
Answers.UserDisplayName: a-am
Body: <p>In my plugin I need to loop through an entry's fields and if that field is a field type of "Categories" use that entry field value/s. </p>
  
  <p>This is what I have tried so far.</p>
  
  <pre><code>if(array_key_exists('byCategory', $filterAttributes))
  {
    foreach ($entry-&gt;getFieldLayout()-&gt;getFields() as $key) 
    {
        $field = $key-&gt;getField();
        if($field-&gt;type == "Categories"){
  
           if(!$this-&gt;addFilterdCategories($field,$filterAttributes))
           {
               continue;
           }
        }
     }
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-19T22:43:03.433Z
Comments.Text: What code do you have so far? It may help us to know what your starting point is.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-19T22:59:41.060Z
Comments.Text: @LindseyD I added code I have tried into the original post.
Comments.UserDisplayName: a-am
Tags: <plugin-development>
Title: Loop through an entry's fields and if the field type is "Categories" get that fields value/s
ThreadText: # Loop through an entry's fields and if the field type is "Categories" get that fields value/s
  
  (Asked by: username_0 on 2015-01-19)
  
  In my plugin I need to loop through an entry's fields and if that field is a field type of "Categories" use that entry field value/s.
  
  This is what I have tried so far.
  
  ```
  if(array_key_exists('byCategory', $filterAttributes))
  {
    foreach ($entry->getFieldLayout()->getFields() as $key) 
    {
        $field = $key->getField();
        if($field->type == "Categories"){
  
           if(!$this->addFilterdCategories($field,$filterAttributes))
           {
               continue;
           }
        }
     }
  }
  
  ```
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: What code do you have so far? It may help us to know what your starting point is.  
  > **username_0**: @username_1 I added code I have tried into the original post.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-01-19. Score: 2 | Accepted answer
  
  I believe I have found the answer.
  
  ```
  if(array_key_exists('byCategory', $filterAttributes))
  {
    foreach ($entry->getFieldLayout()->getFields() as $key) 
    {
        $field = $key->getField();
        if($field->type == "Categories"){
  
           if(!$this->addFilterdCategories($entry[$field->handle],$filterAttributes))
           {
               continue;
           }
        }
     }
  }
  
  ```
  
  
  ---
  
  