Hello,
We apologize for the issue you are facing with changing the meta title and description for your dynamic pages using Rank Math. It sounds like you’ve already tried placing the code in both the theme functions and the rank-math.php file without success.
To troubleshoot this issue, please ensure that you are using the correct hooks and that your code is properly formatted. If you are using custom variables or hooks, double-check that they are registered correctly.
If the problem persists, we recommend replying to this ticket with the specific code snippets you are using, and a human agent from the Rank Math Support team will be able to assist you further.
Thank you for raising this concern!
Hello,
Could you please share the code you have in your rank-math.php file in your theme folder?
Meanwhile, here’s the filter you can use and customize to change the title and description for that page:
add_filter( 'rank_math/frontend/title', function( $title ) {
$url = home_url($_SERVER['REQUEST_URI']);
if(strpos($url, '/groups/')) {
return "This is my title";
}
return $title;
});
add_filter( 'rank_math/frontend/description', function( $description ) {
$urldesc = home_url($_SERVER['REQUEST_URI']);
if(strpos($urldesc, '/groups/')) {
return "This is my description";
}
return $description;
});
Looking forward to helping you.
I have found the issue – it was a duplicate URL that should have redirected to the canonical url. The code still works.
Hello,
Please note that Rank Math cannot handle the trailing slash redirections. Here’s our guide you can follow for that:
https://rankmath.com/kb/how-to-redirect-to-urls-with-trailing-slash/
Hope that helps, and 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.