Advertisement
arie_cristianD

change page loop canonical url

Feb 21st, 2024
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  1. function change_paginate_canonical( $canonical_url, $post ) {
  2.     if ( is_front_page() ) {
  3.         $page = get_query_var( 'page', 0 );
  4.         if ( $page >= 2 ) {
  5.             $canonical_url = get_permalink( $post ) . 'page/' . $page . '/';
  6.  
  7.         }
  8.     }
  9.     return $canonical_url;
  10. }
  11.  
  12.  
  13. add_filter(
  14.     'get_canonical_url',
  15.     'change_paginate_canonical',
  16.     99,
  17.     3
  18. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement