WP nonce invalid

Have a quick script to search for untranslated pages, and then returning a translate link. (Polylang makes a new post for a translation, which is then linked to the original.)

All is working well, except the bloody nonce.
$url = admin_url(‘post-new.php?post_type=product&from_post=’ . $ID . ‘&new_lang=’ . $lang);

$nonce_url = wp_nonce_url($url);
Returns a beautifully formatted url, with an invalid nonce:
https://yaddayadda.com/wp-admin/post-new.php?post_type=product&from_post=2851&new_lang=nl&_wpnonce=fb63ac7002

The link in the admin panel reads exactly the same, but with a working nonce:
https://yaddayadda.com/wp-admin/post-new.php?post_type=product&from_post=2851&new_lang=nl&_wpnonce=c17b1a3a2a

I like to think Im alright with WP, but this is breaking my head.
Does anyone have any sort of idea why it is generating invalid links??

Read more here:: WP nonce invalid

Leave a Reply

Your email address will not be published. Required fields are marked *