Jump to content
PWaddict

Add rel="next" and rel="prev" tags for pagination in head section

Recommended Posts

To easily add rel="next" and rel="prev" tags for pagination in head section insert the following hook to your site/ready.php:

$wire->addHookAfter('Page::render', function(HookEvent $event) {

  $page = $event->object;
  if($page->template == 'admin') return;

  $tags = '';
  $config = wire('config');

  if($config->urls->httpNext) {
    $tags .= "<link rel='next' href='{$config->urls->httpNext}'>";
  }

  if($config->urls->httpPrev) {
    $tags .= "<link rel='prev' href='{$config->urls->httpPrev}'>";
  }

  $event->return = str_replace("</head>", $tags . "</head>", $event->return);

});

 

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...