Tell us what you are trying to do?
I'm trying to set the value of yoasts canonical url field (_yoast_wpseo_canonical) to a value stored in a types custom URL field associated with that post if it exists.
Is there any documentation that you are following?
I have not really been able to find much of anything about this problem... which makes me think there is not really a way around it. I know this is probably outside the scope of your support offerings, but you guys are brilliant so I just thought I would pose the question in case one of you had knowledge of how to edit the value of a field with an _ preceding it programatically.
Is there a similar example that we can see?
I have written the following function to try and update it, and it works if I update any other field that doesn't have an underscore in front of it.
Hello. Thank you for contacting the Toolset support.
The code you shared seems OK to me and as you said it works as well but I do not understand exactly what is the issue yet.
You said:
I have written the following function to try and update it, and it works if I update any other field that doesn't have an underscore in front of it.
==>
Do you want to run that code on specific action? Can you please clarify more details.
Thanks so much for your reply. I'm sorry I was not more clear. I want that code to run when a post is updated, which it is. The problem is that the _yoast_wpseo_canonical field never accepts the data because it is a protected field. I was trying to keep all the fields our post editors would need encapsulated in a single section, which is why I wanted this custom URL field to update the _yoast_wpseo_canonical field on save, but at this point I would settle for just being able to insert the yoast field into my content template instead. That may be the easier route. I'm going to try that now and will report back on how it goes.