Sharing an article through phone shares wrong URL when rankmath is active

#75938
  • Resolved Thorsten R.
    Rank Math free

    I have got a very heavy problem with rankmath that my customer is really angry about and I don’t know a solution. For example open this article with your smartphone: https://ladenburg.local-buzz.de/partner-interview-lobdengau-brauerei/

    If you try to share it with the phones’ built in share option (take whatsapp if you want) a completely wrong url will be shared – a custom post type post (always the same one). Disabling rankmath all posts are shared correctly.

    What the hell is that? Anything in the settings I didn’t see?

    I really need a quick solution for that as the site is heavily been visited.

    Kindly Regards,
    Thorsten

Viewing 12 replies - 1 through 12 (of 12 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Sorry for the issue you are facing.

    Assuming you are using the latest version of all the plugins and the themes (please update if not yet), it could be a conflict with one of the plugins or the theme you are using (apart from Rank Math).

    It is just a possibility but one to check. So if you can, check it and if you still don’t find the issue or if you find it is caused by Rank Math, we will be more than happy to login in your site and try to provide you with a solution.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Please let us know if you find the culprit.

    Only the site admin would know and your users won’t be affected by this troubleshooting.

    Looking forward to helping you.

    Hi,

    I know that standard answer for quite a long time πŸ™„ and checking the site health was one of my first things that I checked before contacting your support – everything is okay. As I said before: in our case it’s rankmath that’s causing the described wrong sharing urls. Please see my first post for details again. I provided sensitive data, too. Interesting is that using a share button inside the website everything is working fine – using the main phones’ sharing options the urls are completely wrong and has nothing to do with the actual viewed page.

    Hello,

    It seems your article is being read as a partner CPT which is modifying the canonical URL of the post you shared to the custom post type URL: https://ladenburg.local-buzz.de/partner/ni-hao/. I tried to add the canonical URL explicitly in Rank math meta box Advanced tab but the CPT defined canonical seems to override this. Please get in touch with the CPT support to check as to why this is happening.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hi Michael,

    thanks for trying to help me. Okay, I’ll contact the support of CPT and send them this ticket here.I hope there will be a solution.

    Thanks, I will come back here for reporting.

    Thorten

    Hi Michael,

    me again. I don’t know why but I could reproduce that this piece of code snippet is causing some overwriting – it’s not CPT. This code is used to generate a shortcode in order to query the login user with its’ written posts (CPT posts). As I have no coding experience I don’t know what the problem ist. I updated the sensitive data.

    Thorsten

    Hello,

    Thank you for the follow up.

    The code seems to be custom code added through snippets. If the code was not added by you, please get in touch with the party involved to make the necessary modifications.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    don’t have any contacts to the person anymore ..

    Thorsten

    Hello,

    Like my colleague mentioned, the wrong URL is being passed to the og:url tag which is causing problem. I tried to troubleshoot the issue using the Health check plugin but it’s not seemed to be working. Enabling the Troubleshooting mode shows a blank white page on the frontend. Can you please create a staging site where we can check this issue by deactivating the plugins?

    Looking forward to helping you.

    Hi Pratik,

    I think it’s a misunderstanding by you. I almost answered to Michael that I could reproduce that this piece of code snippet (placed in the sensitive data as a link) is causing some overwriting – it’s not CPT. This code is used to generate a shortcode in order to query the login user with its’ written posts (CPT posts). As I have no coding experience I don’t know what the problem is and the person who sent me the code snippet doesn’t stay in contact with me anymore.

    There’s no need for a staging version – it’s all about the piece of code.

    Regards,
    Thorsten

    Hello,

    Thank you for providing the link to the snippet code. The wp_reset_postdata() function was missing in the query which was causing problem. I update the query and that seemed to have fixed the issue. Can you please confirm?

    Thank you.

    Hello Pratik,

    great, yes that seems to work. Days ago I added an option just to execute the code for logged in users, so the sharing worked for non logged in ones but of course that didn’t fix the problem. Just for learning purposes: what is wp_reset_postdata() for?

    Great support of you, as we detected it’s not a rankmath, but a custom code problem. Nevertheless you helped me. 5 Stars!

    Thorsten

    Hello,

    wp_reset_postdata() ensures that the global $post has been restored to the current post in the main query. It is recommended to use it immediately after every custom WP_Query(). Simply, it is needed to not catch bugs after outputting of some non-standard posts. For example, trying to get the ID of the current post $post->ID, but get the ID of another post (not of current page).

    If you are not into WordPress programming, this should not worry you much. But if you are interested, here are some references: https://developer.wordpress.org/reference/functions/wp_reset_postdata/
    https://docs.w3cub.com/wordpress/functions/wp_reset_postdata/

    Hope that helps. If you have any further question(s), please let us know. 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.

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

The ticket ‘Sharing an article through phone shares wrong URL when rankmath is active’ is closed to new replies.