I need to add rel="nofollow" to the button "Load More" provided by Views Load More, but the problem is that the anchor is created in views_load_more.module (line 91) this way:

$li_next = theme('pager_next',
      'text' => (isset($tags[3]) ? $tags[3] : t($vars['more_button_text'])),
      'element' => $element,
      'interval' => 1,
      'parameters' => $parameters,

But I dont know how to add an attribute to that, when I print_r($li_next), it prints the link.

I have tried this:

function THEMENAME_preprocess_pager_next(&$vars) {
  $vars['#path']['options'] = array('attributes'=>array('rel'=>'nofollow'));

But didn't work


I found the answer myself, and I want to share it in case someone have the same problem in the future.

Just override the theme_pager_next() function in the template.php file of your theme like this:

function YOURTHEME_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] < ($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' => $text, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=>'nofollow')));
    // The next page is not the last page.
    else {
      $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=>'nofollow')));

  return $output;

I've just add 'attributes'=>array('rel'=>'nofollow') to theme() function :)

| improve this answer | |
  • 1
    That is the solution. Unfortunately, theme_pager_next() is not passing 'attributes' to theme_pager_link(). That would be great if you could create a patch for this and submit it for the module.Also consider marking your answer as Approved. – Alexar Apr 25 '15 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.