Created
July 24, 2019 19:27
-
-
Save taciara/c07dc44a41f083744776d086604862ce to your computer and use it in GitHub Desktop.
Problema com url canonical na paginação.
This file contains hidden or 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
| <?php | |
| /* | |
| Supondo que voce tenha um link de paginação parecida com http://seusite.com.br/blog/page/2 | |
| O rel = "canonical" é exibido como http://seusite.com.br/blog/page/2 | |
| Esse filtro serve para deixar o seu canical como: http://seusite.com.br/blog | |
| Evitando assim que o google considere páginas duplicadas | |
| */ | |
| //URL CANONICAL (coloque isso no seu function) | |
| function return_canon () { | |
| $canon_page = get_pagenum_link(1); | |
| return $canon_page; | |
| } | |
| function canon_paged() { | |
| if (is_paged()) { | |
| add_filter( 'wpseo_canonical', 'return_canon' ); | |
| } | |
| } | |
| add_filter('wpseo_head','canon_paged'); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment