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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.