Query pager not showing for administrator I am having an interesting problem with paging the results of a query. The pager is visible to all users except those who are assigned the built-in 'administrator' role. I have tried the code on two separate Drupal installs and the result is the same: the administrator cannot see the pager. The markup is not visible in the page source.

I have tried my solution using both EntityFieldQuery and db_select, but the problem persists. Here is the code for the EntityFieldQuery version:

function build_area_table() {
  $header = array(
    'area_name' =&gt; array(
      'data' =&gt; 'Area',
      'type' =&gt; 'property',
      'specifier' =&gt; 'title',
      'sort' =&gt; 'asc',
    ),
    'level_range' =&gt; array(
      'data' =&gt; 'Level range',
      'type' =&gt; 'field',
      'specifier' =&gt; array('field' =&gt; 'field_area_level_range', 'column' =&gt; 'value'),
      'sort' =&gt; 'desc',
    ),
  );

  $query = new EntityFieldQuery();
  $query = $query-&gt;pager(5); # I have more than 5 rows being returned
  $query = $query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', 'area')
    -&gt;propertyCondition('status', 1)
    -&gt;tableSort($header);

  $result = $query-&gt;execute();

  $nodes = null;
  // $result['node'] contains a list of nids where the title matches
  if (!empty($result['node'])) {
    // You could use node_load_multiple() instead of entity_load() for nodes
    $nodes = node_load_multiple(array_keys($result['node']));
  }

  // do something to output your results here.
  $td = array();
  foreach ($nodes as $area) {
    $td[] = array(
      'area_name' =&gt; array(
        'data' =&gt; l($area-&gt;title, 'node/'. $area-&gt;nid),
        'class' =&gt; array('area-name'),
        ),
        'level_range' =&gt; array(
          'data' =&gt; $area-&gt;field_area_level_range['und'][0]['safe_value'],
          'class' =&gt; array('level-range'),
        ),
    );
  }

  $areaTable = array(
    'area-table' =&gt; array(
      '#theme' =&gt; 'table',
      '#header' =&gt; $header,
      '#rows' =&gt; $td,
      '#empty' =&gt; 'No areas to display.',
    ),
    'area-pager' =&gt; array(
      '#markup' =&gt; theme('pager')
    ),
  );

  return $areaTable;
}


The table is rendered using Drupal 'render' in the template page. Does anyone have any ideas as to what the problem may be? I have read some posts regarding changing the pager ID, but any changes I make do not seem to have any effect.

EDIT: I am not using the Views module, which seems cause a conflict with pagers as reported by many other people.

Thanks!
Looks like I found the answer. It appears easier (and more efficient) to use the db_select instead, at least for the number of fields I am sorting on. As suspected it was the pager colliding with another pager on the page, although I am not sure what pager this could be. The pager seems to working fine for all users now that I added '->element(0)' to the db_select. Here is some code:

function build_area_table() {
  $header = array(
    'area_name' =&gt; array(
      'data' =&gt; 'Area',
      'field' =&gt; 'n.title',
      'sort' =&gt; 'asc',
    ),
    'level_range' =&gt; array(
      'data' =&gt; 'Level range',
      'field' =&gt; 'flr.field_area_level_range_value',
      'sort' =&gt; 'asc',
    ),
  );

  $query = db_select('node', 'n')
            -&gt;extend('PagerDefault')-&gt;element(0) # fix displaying pager for all users
            -&gt;extend('TableSort');
  $query-&gt;join('field_data_field_area_level_range', 'flr', 'n.nid = flr.entity_id');
  $result = $query
    -&gt;fields('n', array('nid', 'title'))
    -&gt;fields('flr', array('field_area_level_range_value'))
    -&gt;condition('type', 'area')
    -&gt;limit(2)
    -&gt;orderByHeader($header)
    -&gt;execute();

  # build the table
  $td = array();
  foreach ($result as $area) {
    $td[] = array(
      'area_name' =&gt; array(
        'data' =&gt; l($area-&gt;title, 'node/'. $area-&gt;nid),
        'class' =&gt; array('area-name'),
        ),
        'level_range' =&gt; array(
          'data' =&gt; format_area_level_range($area-&gt;field_area_level_range_value),
          'class' =&gt; array('level-range'),
        ),
    );
  }    

  $areaTable = array(
    'area-pager' =&gt; array(
      '#markup' =&gt; theme('pager')
    ),
    'area-table' =&gt; array(
      '#theme' =&gt; 'table',
      '#header' =&gt; $header,
      '#rows' =&gt; $td,
      '#empty' =&gt; 'No areas to display.',
    ),
  );

  return $areaTable;
}


I could probably achieve the same using EFQ, although I can't find an EFQ version of '->element()'. I tried specifying the element via theme like so:

theme('pager', array('element' =&gt; 0))


but there would need to be some kind of check based on the user role, as 0 works for administrators but not for other roles and vice versa. Hopefully this can save someone else some time as well!