AB Entry IDs documentation

AB Entry IDs works like the {exp:query} module where you would give it an SQL query and get a result. The difference is that instead of looping the results AB Entry IDs will return a single variable: {ab_entry_ids}. This variable contains a |-separated list of entry_ids and can be used as a parameter in other tags (ie. the {exp:channel:entries} tag. It will usually be more efficient than using {exp:query} in conjunction with {exp:channel:entries} - as only two queries will be run, instead of one query + one query for each loop iteration.


  • Download and unzip ab_entry_ids.ee2_addon.zip
  • Copy the contents of system/expressionengine/third_party/ from the zip to system/expressionengine/third_party/ on your EE install
  • In the backend, navigate to Addons -> Modules and then activate the "AB Entry IDs" addon.
  • Voilá! The {exp:ab_entry_ids} tag is now ready for use.

Basic usage

{exp:ab_entry_ids sql="SELECT entry_id FROM exp_channel_titles WHERE channel_id=1"}

{if ab_has_results}
{exp:channel:entries entry_id="{ab_entry_ids}"}

<span>Sorry, no results.</span>


Use with AB Pagination

We built this addon to help users of AB Pagination who wanted to use {exp:query} but still control their pagination.

Here's an example of how it would be used with AB Pagination (as an alternative to {exp:query}):

{exp:ab_entry_ids sql="SELECT entry_id FROM exp_channel_titles WHERE title LIKE '%this%'"}
{exp:channel:entries entry_id="{ab_entry_ids}" limit="2"}
{if abp_has_previous}
<a class="next" href="{abp_previous_link}">&larr; prev</a>
<span class="atStart">&larr; prev</span>
{abp_pages padding="no"}
{if abp_is_current}
<span class="this-page">{abp_num}</span>
<a href="{abp_link}">{abp_num}</a>
{if abp_has_next}
<a class="next" href="{abp_next_link}">next &rarr;</a>
<span class="atStart">next &rarr;</span>
<div class="results">({abp_total_entries} uploads)</div>


  • sql - required, the sql you wish to run
  • separator - optional, defaults to the standard EE separator: |
  • col_name - optional, defaults to "entry_id" - using this you can get any other col returned as a separated list
  • results_tag_name - optional, defaults to "entry_ids" - it makes sense to change this if you change the col_name (ie. if you want to get a comma separated list of screen names you'd probably rename this to "screen_names" and use {ab_screen_names} in your template
  • tag_prefix - use this if you wish to replace the default "ab_" tag prefix with something else.


AB Entry IDs has one conditional: {ab_has_results}. In addition to this it returns the results of your sql query in the {ab_entry_ids} variable.


Not working?

  • Run your SQL in a tool such as phpMyAdmin. Are you getting results returned? If not, there is something wrong with your SQL.
  • Remeber that you must SELECT the entry_id column. So your SQL must begin with "SELECT entry_id FROM"... of course if you have changed "col_name" (to select something else then entry_id) this must also be reflected in your SQL.