Answers.Body: <p>Try something like this:</p>
  
  <pre><code>{% set author = entry.metaAuthor|length ? entry.metaAuthor[0] : homepage_entry.metaAuthor[0] }}
  
  &lt;meta name="author" content="{{ author }}" /&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-05T06:54:43.127Z
Answers.Text: Hey Brad just a quick question. I know the `ElementCriteriaModel` has an iterable interface, that's why we can loop it to get the entries (by the way, why did you remove that in Craft 3?) but as far as I know the length filter does not change the type of the object (just caches element) and it stays an object. Could you please explain why this is possible since you would pull the first index of an object in your code. I know models have a `toString` to get the title but how can you even fetch the first element? I just want to learn how that works php wise. Thank you very much
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-06T01:05:50.140Z
Answers.Text: Calling `|length`, triggers `ElementCriteriaModel`'s `count()` method, which calls `total()`, which ultimately calls the database and it's no longer an `ElementCriteriaModel`, but an array of results from the database. Relational fields (entries, users, categories, tags, etc.), will always return an array of results, even if their is only one selected, which is why `metaAuthor[0]` works. Of course, this is all pointless in Craft 3 as ElementCriteriaModel is no longer a thing, too. :)
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-07T18:53:59.020Z
Answers.Text: on Homepage getting error: `Impossible to access a key ("0") on a string variable ("Author Name").`
Answers.UserDisplayName: frshjb373
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-07T23:37:53.777Z
Answers.Text: @frshjb373 Can you update your original question with the code you're using when you get that error?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-21T21:30:40.223Z
Answers.Text: @BradBell, I have updated my question to include additional information.
Answers.UserDisplayName: frshjb373
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-04T21:26:30.753Z
Answers.LastActivityDate: 2017-12-04T21:26:30.753Z
Answers.UserDisplayName: Brad Bell
Body: <p>After running Craft update I'm getting error on the meta author, meta description and meta keywords fields. Any idea how to resolve issue?</p>
  
  <blockquote>
    <p>Recoverable error<br>
    Object of class Craft\ElementCriteriaModel could not be converted to string</p>
  </blockquote>
  
  <p>Error Output:
  <a href="https://i.sstatic.net/zJUqD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zJUqD.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Template Code:</strong></p>
  
  <pre><code>{% set site_title = 'site title here' %}
  
  {#
      ENTRY FALLBACK
      Not all pages have entries associated with them, e.g. search results, login page, etc.
  #}
  {% if entry.id is not defined %}
      {% set entry = craft.entries.id(2) %}
  {% endif %}
  
  {#
     HOMEPAGE DATA
     Used as a fallback for when meta values don't exist in this entry
  #}
  {% set homepage_entry = craft.entries.id(2) %}
  
  
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
      &lt;title&gt;{{ entry.id == '2' ? site_title : entry.title ~ ' &gt; ' ~ site_title }}&lt;/title&gt;
      &lt;meta name="author" content="{{ entry.metaAuthor ? entry.metaAuthor : homepage_entry.metaAuthor }}" /&gt;
      &lt;meta name="description" content="{{ entry.metaDescription ? entry.metaDescription : homepage_entry.metaDescription }}" /&gt;
      &lt;meta name="keywords" content="{{ entry.metaKeywords ? entry.metaKeywords|join(',') : homepage_entry.metaKeywords|join(',') }}" /&gt;
      &lt;link rel="shortcut icon" href="images/favicon.ico" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="/css/all.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="/css/nav.css"&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>Any idea what issue is, how to resolve and why this broke? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-01T22:30:49.903Z
Comments.Text: Is `metaAuthor` an entries field?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-04T18:54:23.353Z
Comments.Text: @BradBell, yes, it is. It was working fine before I updated to latest ver of Craft.
Comments.UserDisplayName: frshjb373
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-21T21:50:30.093Z
Comments.Text: You don't fetch the entries. You just prepare queries but you have to execute them with `.first()`
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-22T18:39:00.733Z
Comments.Text: yes, that did the trick.
Comments.UserDisplayName: frshjb373
Tags: <error><craft-pro><updates>
Title: Recoverable error Object of class Craft\ElementCriteriaModel could not be converted to string after Update
ThreadText: # Recoverable error Object of class Craft\ElementCriteriaModel could not be converted to string after Update
  
  (Asked by: username_0 on 2017-12-01)
  
  After running Craft update I'm getting error on the meta author, meta description and meta keywords fields. Any idea how to resolve issue?
  
  > Recoverable error  
  > Object of class Craft\ElementCriteriaModel could not be converted to string
  
  Error Output:
  [![enter image description here](https://i.sstatic.net/zJUqD.jpg)](https://i.sstatic.net/zJUqD.jpg)
  
  **Template Code:**
  
  ```
  {% set site_title = 'site title here' %}
  
  {#
      ENTRY FALLBACK
      Not all pages have entries associated with them, e.g. search results, login page, etc.
  #}
  {% if entry.id is not defined %}
      {% set entry = craft.entries.id(2) %}
  {% endif %}
  
  {#
     HOMEPAGE DATA
     Used as a fallback for when meta values don't exist in this entry
  #}
  {% set homepage_entry = craft.entries.id(2) %}
  
  <!doctype html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <title>{{ entry.id == '2' ? site_title : entry.title ~ ' > ' ~ site_title }}</title>
      <meta name="author" content="{{ entry.metaAuthor ? entry.metaAuthor : homepage_entry.metaAuthor }}" />
      <meta name="description" content="{{ entry.metaDescription ? entry.metaDescription : homepage_entry.metaDescription }}" />
      <meta name="keywords" content="{{ entry.metaKeywords ? entry.metaKeywords|join(',') : homepage_entry.metaKeywords|join(',') }}" />
      <link rel="shortcut icon" href="images/favicon.ico" />
      <link rel="stylesheet" type="text/css" href="/css/all.css">
      <link rel="stylesheet" type="text/css" href="/css/nav.css">
  </head>
  
  ```
  
  Any idea what issue is, how to resolve and why this broke?
  
  **Tags:** error, craft-pro, updates
  
  > **Comments:**
  > **username_1**: Is `metaAuthor` an entries field?  
  > **username_0**: @username_1, yes, it is. It was working fine before I updated to latest ver of Craft.  
  > **username_2**: You don't fetch the entries. You just prepare queries but you have to execute them with `.first()`  
  > **username_0**: yes, that did the trick.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-12-04. Score: 1
  
  Try something like this:
  
  ```
  {% set author = entry.metaAuthor|length ? entry.metaAuthor[0] : homepage_entry.metaAuthor[0] }}
  
  <meta name="author" content="{{ author }}" />
  
  ```
  
  > **Comments:**
  > **username_2**: Hey username_1 just a quick question. I know the `ElementCriteriaModel` has an iterable interface, that's why we can loop it to get the entries (by the way, why did you remove that in Craft 3?) but as far as I know the length filter does not change the type of the object (just caches element) and it stays an object. Could you please explain why this is possible since you would pull the first index of an object in your code. I know models have a `toString` to get the title but how can you even fetch the first element? I just want to learn how that works php wise. Thank you very much  
  > **username_1**: Calling `|length`, triggers `ElementCriteriaModel`'s `count()` method, which calls `total()`, which ultimately calls the database and it's no longer an `ElementCriteriaModel`, but an array of results from the database. Relational fields (entries, users, categories, tags, etc.), will always return an array of results, even if their is only one selected, which is why `metaAuthor[0]` works. Of course, this is all pointless in Craft 3 as ElementCriteriaModel is no longer a thing, too. :)  
  > **username_0**: on Homepage getting error: `Impossible to access a key ("0") on a string variable ("Author Name").`  
  > **username_1**: @username_0 Can you update your original question with the code you're using when you get that error?  
  > **username_0**: @username_1, I have updated my question to include additional information.  
  
  ---
  
  