When I save <RichText />s content into my attributes and want to use this with render_callback in php, it get's kinda messy. As soon as the text contains RichText (bold, italic, line-breaks etc.), $attributes stores it really complicated

attributes: {
    description: {
        type: "text",
        // no source, so it goes straight into the html comment, nice for dynamic rendering

"render_callback" => function( $attributes ) {
    return "<p>" . $attributes["description"] . "</p>"

// var_dump($attributes["description"]
array(3) {
    string(24) "Rendering RichText with "
    array(5) {
      string(6) "strong"
      string(10) "_domReact4"
      array(1) {
        string(3) "php"
    string(22) " is a pain in the a..."

I guess there is a reason why they save RichText like this. Question now is:

How can I use it when rendering dynamically? Is there some function I don't know of? Like: wp_decode_richtext()

1 Answer 1


The attribute in question should have the type of "string" so that it would be rendered properly.

attributes: {
    description: {
        type: "string",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.