luuhoangphong

Fix canonical for subpage

Oct 7th, 2022
23
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. add_filter('wpseo_canonical', 'my_wpseo_canonical');
  2. function my_wpseo_canonical($canonical) {
  3.     if (is_paged()) {
  4.         if (is_home()) {
  5.             return home_url();
  6.         }
  7.  
  8.         if (is_archive()) {
  9.             $url = get_category_link(get_queried_object_id());
  10.             return $url;
  11.         }
  12.     }
  13.     return $canonical;
  14. }
Advertisement
Comments
  • luuhoangphong
    3 years
    # text 0.12 KB | 0 0
    1. canonical cho các subpage xem chi tiết tại https://luuhoangphong.com/cach-chan-google-index-phan-trang-page-2-page-3/
Add Comment
Please, Sign In to add comment