Problem with canonical on mylisting theme

#731300
  • Resolved Mohammad Fattahi
    Rank Math free

    Hi there
    Im using rank math on wordpress with mylisting theme.
    The problem that exists is that when the rankmath is active, the listing tag pages are canonical on one page, and when the rankmath is deactivated, this problem is solved. Even if we set canonical on one of these tags manually when the rankmath is active, it doesn’t work. Is this a rankmath bug? Is there a code that can solve this problem and make each page canonical on its own when a canonical hand is defined for it?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hello,

    I’m sorry to hear about the issue you’re facing with Rank Math and your MyListing theme. It sounds like there might be a conflict between Rank Math and the theme that’s causing the canonical tags to not work as expected.

    To address this, you can try the following steps:

    1. Check for Plugin Conflicts: Deactivate all other plugins except for Rank Math and see if the issue persists. If the problem goes away, reactivate your plugins one by one to identify the conflicting plugin.

    2. Theme Conflict: Switch to a default WordPress theme like Twenty Twenty-One and see if the issue still occurs. If it doesn’t, then the problem might be with your current theme.

    3. Update Rank Math: Ensure that you are using the latest version of Rank Math to rule out any known issues that might have been resolved in the latest update.

    If none of these steps resolve the issue, please feel free to reach out to our support team by assigning this ticket to them using the available button. They will be able to provide further assistance in resolving this matter.

    Thank you for bringing this to our attention, and we appreciate your patience as we work to resolve this issue for you.

    Sources:
    How to Fix ā€œDuplicate, Google Chose Different Canonical than Userā€ Ā» Rank Math
    Setting Canonical URLs in Rank Math Ā» Rank Math
    Alternate Page with Proper Canonical Tag Status in Google Search Console Ā» Rank Math
    How to NoIndex Paginated Pages Ā» Rank Math
    How to Disable All Rank Math Generated SEO Tags Ā» Rank Math

    Hello,

    Thank you for your patience.

    Could you please share example URLs of your listing so we can create a filter for them?

    Meanwhile, here’s a sample filter to get you started and try to modify it to match your listings:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	global $wp;
    	$current_slug = home_url( $wp->request );
    
    	if ( is_paged()) {
    		$canonical = $current_slug . '/';
    	}
    	return $canonical;
    });

    Please note that the above filter is for paginated URLs to have a self-referencing canonical and needs to be customized further. Hereā€™s a guide to adding the filter to your website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to helping you.

    Hello,

    Please try this code instead:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	global $wp;
    	$current_slug = home_url( $wp->request ) . '/';
    
    	if (strpos($current_slug, '/ads-tag')) {
    		$canonical = $current_slug;
    	}
    
    	return $canonical;
    });

    Let us know how that goes. Looking forward to helping you.

    Hello again
    Thank you very much. With the new code, this problem has been solved. I am really grateful
    There is only one problem
    When this code is executed, it is no longer possible to canonicalize a page manually, and the canonicalization that is placed on a page does not work. Can this also be fixed with the code?
    Thank you in advance

    Hello,

    Thank you for your patience.

    Yes, the code forces the canonical of all the URLs with ads-tag.

    In this case, please update the filter to this one so you can still customize the canonical URL via the Advanced tab in Rank Math:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	global $wp;
    	$current_slug = home_url( $wp->request ) . '/';
    
    	if (strpos($current_slug, '/ads-tag') && empty($canonical)) {
    		$canonical = $current_slug;
    	}
    
    	return $canonical;
    });

    Hope that helps.

    Hello
    Your support is really great, thank you very much
    Thank you for the new code, but I replaced this code with the previous one, it did not work for the original canonicals on their own page, also didnā€™t work for manual canonicals (the previous canonical code worked on the same pages, only manual canonicals did not work anymore)
    Thanks in advance

    Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello again
    thank you
    I have sent the login access to the panel
    When you enter the panel, from the top right, the third one that has a location icon is an ads (listing), and the fifth subcategory is a ads-tag.
    Thanks in advance

    Hello,

    I have replaced the filter you were using with the following one:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
     global $wp;
     global $post;
     $current_slug = home_url( $wp->request ) . '/';
     if (strpos($current_slug, '/ads-tag')  && !metadata_exists('post', $post->ID, 'rank_math_canonical_url') ) {
      $canonical = $current_slug;
     }
    
     return $canonical;
    });

    Now, if you add a custom canonical URL, then it will be used instead of the self-referencing canonical URL.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello Thank you for taking the time to check out the site I did a manual canonical test now, but I check it through inspect without cache in Private, but still manual canonical does not run. Did you test?

    Hello,

    I tested it with this particular page: https://agahi.city/ads-tag/carpet-cleaning/ and it seems that adding the canonical URL explicitly is now working. Please see my video screencast:

    https://i.rankmath.com/v/3ZZ0lt

    Tested on private or incognito tab as well:

    Rank Math support

    Please make sure to clear your website and browser caches after applying the change. You may also check with your hosting provider if your site has server-level caching services. If you do, then please ask them to clear/flush them out.

    If that doesn’t work, please let us know here and we’ll assist you further.

    Thank you.

    Hello
    Thank you very much for doing the test and sending the video because the problem was clearly identified
    When we select a page to display ads from within our site theme, the tags are displayed according to that page, and when you edit any tag from the top of the page, you are actually editing the main page of the ads, not the tag itself.
    To edit the tag and set canonical manually, you need to open the desired tag from the WordPress panel in the listing section and the tags section, and click on the canonical section manually, you will see that this canonical is not included in the sources. I will send you a video to make it clearer

    gemoo.com/tools/upload-video/share/613413945524424704?codeId=vzxa0kap5mGga&card=613413940948439040

    Hello,

    Since the tags are loading as the page in the front end, the filter will check for the custom canonical present in the meta of that page, not the tag that is loading from the backend. Unfortunately, it isn’t possible to check for a custom canonical present in the tag and use it since the actual tag ID is not being loaded in the front end.

    Please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 15 replies - 1 through 15 (of 15 total)

The ticket ‘Problem with canonical on mylisting theme’ is closed to new replies.