Answers.Body: <p>You can probably use the <a href="https://craftcms.com/docs/relations#the-relatedTo-param" rel="nofollow"><code>relatedTo</code></a> parameter with multiple relation criteria:</p>
  
  <pre><code>{% set entries = craft.entries.section(['news', 'press']).relatedTo('or',
      { targetElement: newsTypeCategory, field: 'newsTypeCategoryField' },
      { targetElement: pressTypeCategory, field: 'pressTypeCategoryField' }).order('postDate desc') %}
  </code></pre>
  
  <p>Note that <code>newsTypeCategory</code> and <code>pressTypeCategory</code> should be category IDs (or CategoryModels) so you might need to pull the relevant categories as well:</p>
  
  <pre><code>{% set newsTypeCategory = craft.categories.group('newstype').slug('someslug') %}
  ...
  </code></pre>
  
  <p>Also note that you'll obviously need to change the <code>field</code> values to the real handles for your Categories fields, in the example criteria above.</p>
  
  <p><em>An alternative approach</em> is to use the <a href="https://github.com/TopShelfCraft/SuperSort" rel="nofollow">SuperSort plugin</a> to sort two arrays of entries on the <code>postDate</code> attribute:</p>
  
  <pre><code>{% set newsEntries = craft.entries.section('news').relatedTo(newsTypeCategory) %}
  {% set pressEntries = craft.entries.section('press').relatedTo(pressTypeCategory) %}
  {% set allEntries = newsEntries|merge(pressEntries)|supersort('sortAs', '{ postDate }') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-21T07:39:34.423Z
Answers.LastActivityDate: 2016-10-21T11:02:16.683Z
Answers.LastEditDate: 2016-10-21T11:02:16.683Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.Body: <p>I know this post is a bit old, but I was looking for a similar solution.</p>
  <p>The other solution mentioned helped me get close, but ultimately, I wanted to use a native Twig <a href="https://twig.symfony.com/doc/3.x/filters/sort.html" rel="nofollow noreferrer">sort</a> function, and I came up with this:</p>
  <pre><code>{% set one = craft.entries.section('firstSection').limit(10).all() %}
  {% set two = craft.entries.section('secondSection').limit(10).all() %}
  {% set entries = one|merge(two) %}
  
  {% for entry in entries|sort((a, b) =&gt; a.postDate &lt;=&gt; b.postDate) %}
      {# do stuff here #}
  {% endfor %}
  </code></pre>
  <p>Hope this helps someone else!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-11T11:59:27.617Z
Answers.Text: yes that just helped me a lot!
Answers.UserDisplayName: KSPR
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-11T20:08:39.310Z
Answers.Text: Glad it helped! You can also switch to `b.postDate <=> a.postDate` for DESC order.
Answers.UserDisplayName: Dario Zadro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-25T15:03:34.433Z
Answers.LastActivityDate: 2023-09-25T15:03:34.433Z
Answers.UserDisplayName: Dario Zadro
Body: <p>I got a section called <code>news</code> which contain 2 types of entries: 
  <code>news</code> and <code>press</code>.</p>
  
  <p>Those entries are linked with 2 different categories :<br>
  <code>news</code> entries have category <code>newsType</code><br>
  and <code>press</code> entries have category <code>pressType</code>.</p>
  
  <p>In twig template I want to make 2 entries listing:  </p>
  
  <ol>
  <li>one from <code>news</code> entries and category <code>newstype = A</code>   </li>
  <li>the other from <code>press</code> entries and category <code>presstype = X</code></li>
  </ol>
  
  <p>Then merge those 2 lists to display them ordered by <code>publication date</code>?</p>
  
Tags: <entries><merge><query>
Title: Merge two queries of entries ordered by publication date
ThreadText: # Merge two queries of entries ordered by publication date
  
  (Asked by: username_0 on 2016-10-21)
  
  I got a section called `news` which contain 2 types of entries:
  `news` and `press`.
  
  Those entries are linked with 2 different categories :  
  `news` entries have category `newsType`  
  and `press` entries have category `pressType`.
  
  In twig template I want to make 2 entries listing:
  
  1. one from `news` entries and category `newstype = A`
  2. the other from `press` entries and category `presstype = X`
  
  Then merge those 2 lists to display them ordered by `publication date`?
  
  **Tags:** entries, merge, query
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-10-21. Score: 3
  
  You can probably use the [`relatedTo`](https://craftcms.com/docs/relations#the-relatedTo-param) parameter with multiple relation criteria:
  
  ```
  {% set entries = craft.entries.section(['news', 'press']).relatedTo('or',
      { targetElement: newsTypeCategory, field: 'newsTypeCategoryField' },
      { targetElement: pressTypeCategory, field: 'pressTypeCategoryField' }).order('postDate desc') %}
  
  ```
  
  Note that `newsTypeCategory` and `pressTypeCategory` should be category IDs (or CategoryModels) so you might need to pull the relevant categories as well:
  
  ```
  {% set newsTypeCategory = craft.categories.group('newstype').slug('someslug') %}
  ...
  
  ```
  
  Also note that you'll obviously need to change the `field` values to the real handles for your Categories fields, in the example criteria above.
  
  *An alternative approach* is to use the [SuperSort plugin](https://github.com/TopShelfCraft/SuperSort) to sort two arrays of entries on the `postDate` attribute:
  
  ```
  {% set newsEntries = craft.entries.section('news').relatedTo(newsTypeCategory) %}
  {% set pressEntries = craft.entries.section('press').relatedTo(pressTypeCategory) %}
  {% set allEntries = newsEntries|merge(pressEntries)|supersort('sortAs', '{ postDate }') %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2023-09-25. Score: 1
  
  I know this post is a bit old, but I was looking for a similar solution.
  
  The other solution mentioned helped me get close, but ultimately, I wanted to use a native Twig [sort](https://twig.symfony.com/doc/3.x/filters/sort.html) function, and I came up with this:
  
  ```
  {% set one = craft.entries.section('firstSection').limit(10).all() %}
  {% set two = craft.entries.section('secondSection').limit(10).all() %}
  {% set entries = one|merge(two) %}
  
  {% for entry in entries|sort((a, b) => a.postDate <=> b.postDate) %}
      {# do stuff here #}
  {% endfor %}
  
  ```
  
  Hope this helps someone else!
  
  > **Comments:**
  > **username_3**: yes that just helped me a lot!  
  > **username_2**: Glad it helped! You can also switch to `b.postDate <=> a.postDate` for DESC order.  
  
  ---
  
  