Created
February 14, 2020 14:43
-
-
Save jacmaes/68eb9f6ac6a5bce73b609b4a49af0005 to your computer and use it in GitHub Desktop.
PW pagination in <head> #pw #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Kreativan's gist: https://gist.github.com/kreativan/bddcfa1c923f563d968ff40f2fb4e32e | |
<?php | |
//----------------------------------------------------------------------- | |
// Add rel="next" and rel="prev" tags for pagination in head section | |
//----------------------------------------------------------------------- | |
$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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment