<p>Yes it is. Just include the site id of the the site in your query</p>

<pre><code>set siteId = 2
set entries = craft.entries.section('foo').site(siteId).all()
</code></pre>

<p>if you want to get the current entry for another site</p>

<pre><code>set currentEntrySiteB = craft.entries.id(entry.id).site(2).one()
</code></pre>

<p>If you want to search for disabled entries (for example in CP templates) for other sites you can do</p>

<pre><code>craft.entries.id(entry.id).site(2).enabledForSite(false).one()
</code></pre>

CC BY-SA 4.0
2018-05-09T11:33:43.090Z
Is it possible to aggregate multiple site's content (for example, news stories) into one query? I don't seem to see a way to include multiple site IDs or handles in an entry query.
Stephen Hamilton
CC BY-SA 4.0
2018-05-09T11:35:45.240Z
@StephenHamilton No you can't https://github.com/craftcms/cms/issues/2854
Robin Schambach
CC BY-SA 4.0
2018-05-09T12:00:47.603Z
Thanks @Robin, gutted I didn't see that before getting this far with a build...
Stephen Hamilton
CC BY-SA 3.0
2018-02-27T14:33:45.677Z
2018-02-27T15:56:11.253Z
2018-02-27T15:56:11.253Z
Robin Schambach
<p>I needed to aggregate blog posts entries from ~20 schools (multi-sites) and display them on the main site. Like others, I realised way to0 late in the development that this wasn't an out of the box feature. However by using the Twig array <a href="https://twig.symfony.com/doc/2.x/filters/merge.html" rel="nofollow noreferrer">merge filter</a> you can build an array of aggregated entries from your multi-sites. </p>

<p>Then, using the <a href="https://github.com/TopShelfCraft/SuperSort" rel="nofollow noreferrer">superSort</a> plugin you can subsequently sort the merged array into whatever order you like, chronological in our case. </p>

<p>On this particular multi-site setup, we use a lightswitch <code>showOnMainSite</code> that admin users can switch to the on position to select what entries are pulled through to the main site. In the example below, we use the search filter to filter the entries output accordingly. </p>

<p>Here's a simplified version:</p>

<pre><code>{#-- create an empty array --#}
{% set multiSiteEntries = [] %}

{#-- fetch the multi-site IDS using the getSitesByGroupId method --#}
{% set sites = craft.app.sites.getSitesByGroupId(2) %}

    {#-- loop through the sites in groupId 2 using the site.id, searching for the showOnMainSite lightswitch field --#}
    {% for site in sites %}

        {#-- add retrieved site entries to the multiSiteEntries array --#}
        {% set multiSiteEntries = multiSiteEntries|merge(
            craft.entries().
            siteId(site.id).
            section('blog').
            search('showOnMainSite:1').
            all()) 
        %}

    {% endfor %}

{#-- loop through our populated array of multi-site enries and use the superSort plugin to sort them chronologically --#}
{% for entry in multiSiteEntries|supersort('rsortAs', '{{ object.postDate|date("U") }}') %}

    {#-- our multi-site entries output --#}
    &lt;a href="{{ entry.url }}"&gt;
        {{ entry.title }} | {{ entry.postDate|date('jS F Y')}}
    &lt;/a&gt;

{% endfor %}
</code></pre>

<p>We limit each site output to 3 entries, so overall we are pulling ~60 entries in from 20 multi-sites to use as a landing page for end users to browse at a glance all the news across the 20 schools. </p>

CC BY-SA 4.0
2019-03-11T10:20:09.003Z
As of 3.2 (d017022) Craft supports this feature request in the op


  [1]: https://github.com/craftcms/cms/commit/d01702278bd84b84392e11da72aa4d0b6f4f0943
  [2]: https://github.com/craftcms/cms/issues/2854#issuecomment-471371467
Jamie Taylor
CC BY-SA 4.0
2019-01-18T11:01:36.913Z
2019-01-18T11:01:36.913Z
Jamie Taylor
<p>In multi-site is it possible to access entries between sites in the templates.  Like a feed?   ie. entry "a" on site "A" shows up in an index on site "B", and links back to the entry on site A, not a duplicate of the entry on site "B"?  </p>

<craft3><multi-site>
Craft 3 multisite - are entries accessible between sites?
# Craft 3 multisite - are entries accessible between sites?

(Asked by: username_0 on 2018-02-27)

In multi-site is it possible to access entries between sites in the templates. Like a feed? ie. entry "a" on site "A" shows up in an index on site "B", and links back to the entry on site A, not a duplicate of the entry on site "B"?

**Tags:** craft3, multi-site


---

## 2 answers

### Answer by username_1 on 2018-02-27. Score: 5 | Accepted answer

Yes it is. Just include the site id of the the site in your query
set siteId = 2
set entries = craft.entries.section('foo').site(siteId).all()

if you want to get the current entry for another site
set currentEntrySiteB = craft.entries.id(entry.id).site(2).one()

If you want to search for disabled entries (for example in CP templates) for other sites you can do
craft.entries.id(entry.id).site(2).enabledForSite(false).one()

> **Comments:**
> **username_2**: Is it possible to aggregate multiple site's content (for example, news stories) into one query? I don't seem to see a way to include multiple site IDs or handles in an entry query.  
> **username_1**: @StephenHamilton No you can't https://github.com/craftcms/cms/issues/2854  
> **username_2**: Thanks @Robin, gutted I didn't see that before getting this far with a build...  

---

### Answer by username_3 on 2019-01-18. Score: 3

I needed to aggregate blog posts entries from ~20 schools (multi-sites) and display them on the main site. Like others, I realised way to0 late in the development that this wasn't an out of the box feature. However by using the Twig array merge filter you can build an array of aggregated entries from your multi-sites. 
Then, using the superSort plugin you can subsequently sort the merged array into whatever order you like, chronological in our case. 
On this particular multi-site setup, we use a lightswitch showOnMainSite that admin users can switch to the on position to select what entries are pulled through to the main site. In the example below, we use the search filter to filter the entries output accordingly. 
Here's a simplified version:
{#-- create an empty array --#}
{% set multiSiteEntries = [] %}

{#-- fetch the multi-site IDS using the getSitesByGroupId method --#}
{% set sites = craft.app.sites.getSitesByGroupId(2) %}

    {#-- loop through the sites in groupId 2 using the site.id, searching for the showOnMainSite lightswitch field --#}
    {% for site in sites %}

        {#-- add retrieved site entries to the multiSiteEntries array --#}
        {% set multiSiteEntries = multiSiteEntries|merge(
            craft.entries().
            siteId(site.id).
            section('blog').
            search('showOnMainSite:1').
            all()) 
        %}

    {% endfor %}

{#-- loop through our populated array of multi-site enries and use the superSort plugin to sort them chronologically --#}
{% for entry in multiSiteEntries|supersort('rsortAs', '{{ object.postDate|date("U") }}') %}

    {#-- our multi-site entries output --#}
    
        {{ entry.title }} | {{ entry.postDate|date('jS F Y')}}
    

{% endfor %}

We limit each site output to 3 entries, so overall we are pulling ~60 entries in from 20 multi-sites to use as a landing page for end users to browse at a glance all the news across the 20 schools.

> **Comments:**
> **username_3**: As of 3.2 (d017022) Craft supports this feature request in the op     [1]: https://github.com/craftcms/cms/commit/d01702278bd84b84392e11da72aa4d0b6f4f0943   [2]: https://github.com/craftcms/cms/issues/2854#issuecomment-471371467  

---

