Jump to content

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


PWaddict
 Share

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 7
  • Thanks 2
Link to comment
Share on other sites

  • PWaddict changed the title to Add rel="next" and rel="prev" tags for pagination in head section

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...