Answers.Body: <p>You're close!</p>
  
  <p>In your entry query, change <code>.relatedMarkets([allMarkets])</code> to <code>.relatedTo(allMarkets)</code> (use <a href="https://docs.craftcms.com/v3/relations.html" rel="nofollow noreferrer"><code>relatedTo</code></a> instead and you don't need array brackets).</p>
  
  <p>Final code looks like:</p>
  
  <pre><code>{% set allMarkets = entry.relatedMarkets.all() %}
  {% set currentID = entry.id %}
  
  {% set expertBlog = craft.entries()
      .section('blog')
      .orderBy('postDate desc')
      .expertOpinion(true)
      .relatedTo(allMarkets)
      .id(['not', currentID])
      .limit(3)
  %}
  
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-26T15:46:41.060Z
Answers.LastActivityDate: 2020-05-26T15:46:41.060Z
Answers.UserDisplayName: RitterKnight
Answers.Body: <p>I did something similar with entry counts. The trick was to get the ids from the first query and then use that as the sourceElement for the relatedTo query.</p>
  
  <pre><code>{% set userMugQuery = craft.entries().section('userMugs').relatedTo({targetElement: entry}) %}
  {% set userMugAssetQuery = craft.assets()
      .volume('userAssets')
      .relatedTo({ sourceElement: userMugQuery.ids(), field: 'userAssets' })
  %}
  {% set userMugCount = userMugQuery.count() %}
  {% set userMugAssetCount = userMugAssetQuery.count() %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-22T14:20:58.797Z
Answers.LastActivityDate: 2020-05-22T14:20:58.797Z
Answers.UserDisplayName: Leevi Graham
Body: <p>I'm wanting to show related articles based on the current article's related Markets.</p>
  
  <p>How do I get the current markets and filter relevant posts based on those related markets? This is what I have so far but doesn't seem correct.</p>
  
  <pre><code>{% set allMarkets = entry.relatedMarkets.all() %}
  {% set currentID = entry.id %}
  
  {# Get Related Articles Based on Markets #}
  {% set expertBlog = craft.entries()
      .section('blog')
      .orderBy('postDate desc')
      .expertOpinion(true)
      .relatedMarkets([allMarkets])
      .id(['not', currentID])
      .limit(3) %}
  
        &lt;h3 class="f3-l f3-xl fw5 mt0-l mt0-xl b tc"&gt;Enjoyed this article? Keep reading more expert insights...&lt;/h3&gt;
        &lt;div class="flex flex-wrap cf mb4 nl3-m nr3-m nl3-l nr3-l nl3-xl nr3-xl"&gt;
            {% cache %}
            {% for entry in expertBlog %}
                {% set columns = 'w-100 w-50-m w-33-l w-33-xl' %}
                {% include "_partials/lists/blog/_cards_blog_article_authors_expert.twig" %}
            {% endfor %}
            {% endcache %}
        &lt;/div&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-22T15:30:33.847Z
Comments.Text: In your entry query, change ``.relatedMarkets([allMarkets])`` to ``.relatedTo(allMarkets)`` (use relatedTo instead and you don't need brackets).
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-26T15:28:12.837Z
Comments.Text: Thanks if you post as an official answer I will accept.
Comments.UserDisplayName: Dan Lee
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-26T15:47:08.763Z
Comments.Text: Dan: You bet. Done.
Comments.UserDisplayName: RitterKnight
Tags: <craft3>
Title: Query Entries based on current Entry's related Entries
ThreadText: # Query Entries based on current Entry's related Entries
  
  (Asked by: username_0 on 2020-05-22)
  
  I'm wanting to show related articles based on the current article's related Markets.
  
  How do I get the current markets and filter relevant posts based on those related markets? This is what I have so far but doesn't seem correct.
  
  ```
  {% set allMarkets = entry.relatedMarkets.all() %}
  {% set currentID = entry.id %}
  
  {# Get Related Articles Based on Markets #}
  {% set expertBlog = craft.entries()
      .section('blog')
      .orderBy('postDate desc')
      .expertOpinion(true)
      .relatedMarkets([allMarkets])
      .id(['not', currentID])
      .limit(3) %}
  
        <h3 class="f3-l f3-xl fw5 mt0-l mt0-xl b tc">Enjoyed this article? Keep reading more expert insights...</h3>
        <div class="flex flex-wrap cf mb4 nl3-m nr3-m nl3-l nr3-l nl3-xl nr3-xl">
            {% cache %}
            {% for entry in expertBlog %}
                {% set columns = 'w-100 w-50-m w-33-l w-33-xl' %}
                {% include "_partials/lists/blog/_cards_blog_article_authors_expert.twig" %}
            {% endfor %}
            {% endcache %}
        </div>
  
  ```
  
  **Tags:** craft3
  
  > **Comments:**
  > **username_1**: In your entry query, change ``.relatedMarkets([allMarkets])`` to ``.relatedTo(allMarkets)`` (use relatedTo instead and you don't need brackets).  
  > **username_0**: Thanks if you post as an official answer I will accept.  
  > **username_1**: Dan: You bet. Done.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-05-26. Score: 1 | Accepted answer
  
  You're close!
  
  In your entry query, change `.relatedMarkets([allMarkets])` to `.relatedTo(allMarkets)` (use [`relatedTo`](https://docs.craftcms.com/v3/relations.html) instead and you don't need array brackets).
  
  Final code looks like:
  
  ```
  {% set allMarkets = entry.relatedMarkets.all() %}
  {% set currentID = entry.id %}
  
  {% set expertBlog = craft.entries()
      .section('blog')
      .orderBy('postDate desc')
      .expertOpinion(true)
      .relatedTo(allMarkets)
      .id(['not', currentID])
      .limit(3)
  %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2020-05-22. Score: 0
  
  I did something similar with entry counts. The trick was to get the ids from the first query and then use that as the sourceElement for the relatedTo query.
  
  ```
  {% set userMugQuery = craft.entries().section('userMugs').relatedTo({targetElement: entry}) %}
  {% set userMugAssetQuery = craft.assets()
      .volume('userAssets')
      .relatedTo({ sourceElement: userMugQuery.ids(), field: 'userAssets' })
  %}
  {% set userMugCount = userMugQuery.count() %}
  {% set userMugAssetCount = userMugAssetQuery.count() %}
  
  ```
  
  
  ---
  
  