Hello, I’m sorry to hear about the issue you’re facing with changing the canonical URL on your dynamic pages. It seems like you’re trying to dynamically change the canonical URL using a filter in your theme’s functions file, but it’s not reflecting the changes on the pages.
Based on the information provided, it seems like you’re using a custom filter to modify the canonical URL for dynamic pages. However, it’s possible that the filter isn’t being applied correctly or there might be a conflict with other plugins or theme functionalities.
To further investigate and resolve this issue, I recommend reaching out to our support team directly from here. Our support team will be able to assist you in identifying the cause of the issue and provide you with a solution to dynamically change the canonical URL for your dynamic pages.
If you have any other questions or need further assistance, please feel free to let us know.
Sources:
Alternate Page with Proper Canonical Tag Status in Google Search Console » Rank Math
How to Fix ‘Duplicate Without User-Selected Canonical’ Status in Google Search Console » Rank Math
How to Fix “Duplicate, Google Chose Different Canonical than User” » Rank Math
How to Fix ‘Duplicate, Submitted URL Not Selected as Canonical’ Issue in Google Search Console » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
Hello,
Could you please share the actual URL so we can check? You can add it in the sensitive data section.
Meanwhile, are you trying to achieve a self-referencing canonical on those?
If so, please try applying this filter on your site to set a self-referencing canonical on URLs:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
$url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(strpos($url,'?jobId=') !== false){
return $url;
}
return $canonical;
});
And here’s a guide to adding the filter to your website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how this goes.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
I tried the code you gave me but still refers to wrong canonical url
Hello,
Please replace the existing code with this one and check if it resolves the issue.
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
// Check if the current URL contains the 'jobId' parameter
if ( isset( $_GET['jobId'] ) ) {
// Create a new canonical URL based on the current URL
$canonical = home_url( $_SERVER['REQUEST_URI'] );
}
return $canonical;
});
This code checks if the ‘jobId’ parameter is present in the URL. If it is, it dynamically sets the canonical URL based on the current URL.
If the problem persists, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.

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.
Hey, thanks for helping. I was confused because I already tried the exact same code you gave me, but now I tried something different: Actually I had inserted the filter into the template file but that didn’t work. Now I tried to insert the code into functions.php for the first time and lo and behold, it works. Is it intended that the filters do not go into template files from themes?
Hello,
We are glad that worked.
Regarding the filter code, it should be applied to your theme’s functions.php file. You can also use other methods mentioned in this guideline: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps and please don’t hesitate to let us know if you have any other questions.
Thank you.
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.