Views Pager Add rel="nofollow to ALL Pager Links In Drupal 7 I am trying to add rel="nofollow" to ALL of the pager links in views. The closest I have got is to add the nofollow to next links, but I want it to include previous pages as well as "First" and "Last".

P.S. We specifically want the rel="nofollow" attribute to all pager links, we are not looking for other solutions (noindex, block with robots.txt, or rel=next/prev).

This is the code I am currently using:

function mytheme_pager_next($variables) {
  $text = $variables['text'];
  $element = $variables['element'];
  $interval = $variables['interval'];
  $parameters = $variables['parameters'];
  global $pager_page_array, $pager_total;
  $output = '';
  // If we are anywhere but the last page
  if ($pager_page_array[$element] &lt; ($pager_total[$element] - 1)) {
    $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
    // If the next page is the last page, mark the link as such.
    if ($page_new[$element] == ($pager_total[$element] - 1)) {
      $output = theme('pager_last', array('text' =&gt; $text, 'element' =&gt; $element, 'parameters' =&gt; $parameters,'attributes'=&gt;array('rel'=&amp;gt;'nofollow')));
    }
    // The next page is not the last page.
    else {
      $output = theme('pager_link', array('text' =&gt; $text, 'page_new' =&gt; $page_new, 'element' =&gt; $element, 'parameters' =&gt; $parameters,'attributes'=&gt;array('rel'=&gt;'nofollow')));
    }
  }
  return $output;
}
Not sure of a hook right now for something cleaner. An alternative that will allow you to do what you want,

function hook_views_post_render(&amp;$view, &amp;$output, &amp;$cache) {
    dpm($output);
}


You can use a regex, something like, 

(&lt;li.*pager-item.*&gt;&lt;a)(.*)


That will give you two groups.
- Group one with every list of items and the opening tag of the anchor.
- Group two with the rest of the line

You can use this to iterate over and add in between both groups, 

rel="nofollow"




Of course, you post an answer and find some information. You may want to see if you find these hooks useful, https://drupal.stackexchange.com/a/140867