Answers.Body: <p>If I understand correctly, you could do this in one query:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set vetCategoryID = 437950 %}
  
  {# Get all entries where personnelType is empty OR equals vetCategoryID #}
  {% set query  = craft.entries()
      .section('veterinarians')
      .personnelType([':empty:', vetCategoryID])
      .limit(10) %}
  
  {# Paginate #}
  {% paginate query as pageInfo, pageEntries %}
  
  {% for entry in pageEntries %}
  {{ entry.title }} &lt;br&gt;
  {% endfor %}
  
  {% if pageInfo.prevUrl %}&lt;a href=&quot;{{ pageInfo.prevUrl }}&quot;&gt;Previous Page&lt;/a&gt;{% endif %}
  {% if pageInfo.nextUrl %}&lt;a href=&quot;{{ pageInfo.nextUrl }}&quot;&gt;Next Page&lt;/a&gt;{% endif %}
  </code></pre>
  <p>See documentation on <a href="https://craftcms.com/docs/3.x/categories-fields.html#querying-elements-with-categories-fields" rel="nofollow noreferrer">querying Categories fields</a> and <a href="https://craftcms.com/docs/3.x/dev/tags.html#paginate" rel="nofollow noreferrer">pagination</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-09T13:32:55.560Z
Answers.Text: You're right, that's much better and won't need explanatory variable names. Thanks. Funny enough, I was reading that part of the doc and when I saw `:empty:` my brain went "Yea, that's all we need, no need to read anymore" :-D
Answers.UserDisplayName: InanisAtheos
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-09T09:44:06.430Z
Answers.LastActivityDate: 2022-03-09T09:44:06.430Z
Answers.UserDisplayName: Oli
Answers.Body: <p>The answer to this was simpler than I thought. So simple, that I thought I had tried it already.</p>
  <pre><code>{% set entries          = craft.entries.id(merged) %}
  
      {% for entry in entries %}
          {{ entry.id }}: {{ entry.title }}
      {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-09T09:43:08.230Z
Answers.LastActivityDate: 2022-03-09T09:43:08.230Z
Answers.UserDisplayName: InanisAtheos
Body: <p>I have 2 arrays of entry ID's that I need to merge and generate an entries object that I can iterate through and paginate. The reason for doing it this way at all, is that I need to display entries with a specific category, and those without any category as per the code below.</p>
  <p>Perhaps I'm approaching this all wrong and there's a different way to get the entries.</p>
  <pre><code>{% set vetCategoryID        = 437950 %}
      {% set noPersonnelType  = craft.entries.section('veterinarians').personnelType(':empty:').limit(null).ids() %}
      {% set vets             = craft.entries.section('veterinarians').personnelType(vetCategoryID).limit(null).ids() %}
      {% set merged           = noPersonnelType|merge(vets) %}
      
      {# this displays all, but makes pagination impossible, so no dice. #}
      {% for item in merged %}
          {% set entry = craft.entries({id: item}) %}
          {{ dd(entry) }}
      {% endfor %}
  </code></pre>
  <p>I tried using <code>{% set entries = craft.entries(merged) %}</code> but that doesn't work at all.</p>
  <p>Searching here gives me this question: <a href="https://craftcms.stackexchange.com/questions/17155/converting-array-of-entries-to-an-array-of-ids">Converting array of entries to an array of ids</a>, but it's the opposite problem.</p>
  
Tags: <templating><entries>
Title: Construct entries object from an array of IDs
ThreadText: # Construct entries object from an array of IDs
  
  (Asked by: username_0 on 2022-03-09)
  
  I have 2 arrays of entry ID's that I need to merge and generate an entries object that I can iterate through and paginate. The reason for doing it this way at all, is that I need to display entries with a specific category, and those without any category as per the code below.
  
  Perhaps I'm approaching this all wrong and there's a different way to get the entries.
  
  ```
  {% set vetCategoryID        = 437950 %}
      {% set noPersonnelType  = craft.entries.section('veterinarians').personnelType(':empty:').limit(null).ids() %}
      {% set vets             = craft.entries.section('veterinarians').personnelType(vetCategoryID).limit(null).ids() %}
      {% set merged           = noPersonnelType|merge(vets) %}
      
      {# this displays all, but makes pagination impossible, so no dice. #}
      {% for item in merged %}
          {% set entry = craft.entries({id: item}) %}
          {{ dd(entry) }}
      {% endfor %}
  
  ```
  
  I tried using `{% set entries = craft.entries(merged) %}` but that doesn't work at all.
  
  Searching here gives me this question: [Converting array of entries to an array of ids](https://craftcms.stackexchange.com/questions/17155/converting-array-of-entries-to-an-array-of-ids), but it's the opposite problem.
  
  **Tags:** templating, entries
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-03-09. Score: 3 | Accepted answer
  
  If I understand correctly, you could do this in one query:
  
  ```twig
  {% set vetCategoryID = 437950 %}
  
  {# Get all entries where personnelType is empty OR equals vetCategoryID #}
  {% set query  = craft.entries()
      .section('veterinarians')
      .personnelType([':empty:', vetCategoryID])
      .limit(10) %}
  
  {# Paginate #}
  {% paginate query as pageInfo, pageEntries %}
  
  {% for entry in pageEntries %}
  {{ entry.title }} <br>
  {% endfor %}
  
  {% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl }}">Previous Page</a>{% endif %}
  {% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl }}">Next Page</a>{% endif %}
  
  ```
  
  See documentation on [querying Categories fields](https://craftcms.com/docs/3.x/categories-fields.html#querying-elements-with-categories-fields) and [pagination](https://craftcms.com/docs/3.x/dev/tags.html#paginate).
  
  > **Comments:**
  > **username_0**: You're right, that's much better and won't need explanatory variable names. Thanks. Funny enough, I was reading that part of the doc and when I saw `:empty:` my brain went "Yea, that's all we need, no need to read anymore" :-D  
  
  ---
  
  ### Answer by username_0 on 2022-03-09. Score: 1
  
  The answer to this was simpler than I thought. So simple, that I thought I had tried it already.
  
  ```
  {% set entries          = craft.entries.id(merged) %}
  
      {% for entry in entries %}
          {{ entry.id }}: {{ entry.title }}
      {% endfor %}
  
  ```
  
  
  ---
  
  