I was a little too early with the champagne…
My function only appears to update existing posts correctly, not new posts. If I remove the function, create a new post, add the function in again and re-save, it works. Just not ‘off the bat’.
Does anyone know which direction I should be looking in to resolve this?
Thanks,
Andy.