jquery wysiwyg editor val acf 1

jquery wysiwyg editor val acf

/* You have to find your ACF field, find the textarea within the editor,
get that ID, then setContent using TinyMCE JS API that's built in to
WordPress: */
let description = "Some text!";
let f = acf.getField("your_field_key");
let tinyID = f.$el.find("textarea").attr("id");
let tinyInstance = tinyMCE.editors[tinyID];
tinyInstance.setContent(description);

Here is what the above code is Doing:
1. Get the ACF field object
2. Find the textarea within the editor
3. Get the ID of the textarea
4. Get the TinyMCE instance using the ID
5. Set the content of the TinyMCE instance

Similar Posts