• Hi,
    I have a problem with canonical with the better amp plugin, every canonical is going to the home page in this case <link rel="canonical" href="https://piedfeed.com"/>.
    If I go page 2 https://piedfeed.com/amp/page/2/ 3,4,5… every paginated page has canonical to the home page and I have mismatch content and critical error with WBT.
    Can you change that so for page 2 canonical to be <link rel="canonical" href="https://piedfeed.com/page/2/"/> 3,4,5…?
    Also with categories example -> amp/category/page/4/ canonical is /category -> mismatch content.

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    • This topic was modified 7 years, 3 months ago by bdbrown.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello Antonio,
    I sorted this out and your problem will be gone in the next update.

    I hope that the next update will come soon. I also have the some issue with canonical URL for paged archives!

    I made a temporal fix!
    I edit the function better_amp_get_canonical_url() from the file better-amp/includes/functions/theme-functions.php
    I change this part of the code:

    if ( ! empty( $term ) ) {
    				$queried_terms = $GLOBALS['wp_query']->tax_query->queried_terms;
    				/**
    				 * Check if term archive query is for multiple terms
    				 */
    				if (
    					! isset( $queried_terms[ $term->taxonomy ]['terms'] ) ||
    					count( $queried_terms[ $term->taxonomy ]['terms'] ) <= 1
    				) {
    					$term_link = get_term_link( $term, $term->taxonomy );
    
    					if ( $term_link && ! is_wp_error( $term_link ) ) {
    						$canonical = $term_link;
    					}
    				}
    			}
    

    with:

    
    if ( ! empty( $term ) ) {
    				global $wp;
    				$queried_terms = $GLOBALS['wp_query']->tax_query->queried_terms;
    				/**
    				 * Check if term archive query is for multiple termsss
    				 */
    				if (
    					! isset( $queried_terms[ $term->taxonomy ]['terms'] ) ||
    					count( $queried_terms[ $term->taxonomy ]['terms'] ) <= 1
    				) {
    					$term_link = home_url(add_query_arg(array(),$wp->request));
    					
    					if ( $term_link && ! is_wp_error( $term_link ) ) {
    						$canonical = $term_link;
    					}
    				}
    			}
    

    Now we can see the right canonical URL for paged arhives like categories and tags!

    • This reply was modified 6 years, 10 months ago by Cristescu Bogdan. Reason: The code solution!
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Canonical Problem’ is closed to new replies.