Home › Forums › Gutenberg › Register block preview image with acf_register_block_type? › Reply To: Register block preview image with acf_register_block_type?
(apologies if this is posted twice, got a bug and not sure if it went through)
Just a quick update, I’ll link to a comment I found by Eliot on github. https://github.com/AdvancedCustomFields/acf/issues/264#issuecomment-629558291
Basically says that if you use “get_fields” instead of single “get_field” functions, it won’t pass the data because the name of the fields aren’t declared at that moment in the code execution. You can still pass examples without refactoring your code to use “get_field”, but you have to use the field IDs like so and it will work with “get_fields” :
'example' => [
'attributes' => [
'mode' => 'preview',
'data' => [
"field_5efb9b4a86e4d" => "Titre gauche",
"field_5f29ba5f8e2f1" => "h2",
"field_5efb9b4a86e4f" => "Sous-titre gauche",
"field_5efb9b4a86e51" => "<p>Mauris turpis risus scelerisque mollis interdum tincidunt lectus parturient nibh</p>",
"field_5f08b1ab13927" => ["url" => "http://google.com", "target" => "_blank", "title" => "Lien gauche"],
"field_5f0c252bdce4e" => 0,
"field_5f29c57dad9dc" => "text-white",
"field_5f29c59dad9dd" => "opacity-15",
"field_5f3a04b753a8d" => "Titre droite",
"field_5f3a04a953a8c" => "h2",
"field_5f3a04bd53a8e" => "Sous-titre droite",
"field_5efb9b4a86e52" => "<p>Mauris turpis risus scelerisque mollis interdum tincidunt lectus parturient nibh</p>",
"field_5f08b24c905b3" => ["url" => "http://google.com", "target" => "_blank", "title" => "Lien gauche"],
"field_5f0c2543dce4f" => 0,
"field_5f29c5dbad9de" => "text-white",
"field_5f29c5ebad9df" => "opacity-15",
"is_preview" => 1
]
]
]
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.