I AM LISTENING TO
|
WHAT I LIKE
  • English
  • German

Advanced Custom Fields – Free Your Gutenberg Blocks Data

10. February 2019








Advanced Custom Fields – Free Your Gutenberg Blocks Data

Updated 25.03. : Some function names changed in the latest beta version.

IN BETA

ACF 5.8 Beta introduced an easy way to create your custom Gutenberg blocks. I am already using it heavily for a current project, to easily organize content and media assets.

Really powerful, when combined with Timber as well, which has been the foundation of many of my themes for years now ;)

ORGANIZE YOURSELF

Organizing data using ACF is nice, but sometimes you seek access to that saved block data directly. I hate it when I am confined to boundaries and the data flow is restricted or hidden. I need things to be accessible to choose the creative flow myself.

SIMPLE EXAMPLE

There you go, enjoy some free block data :)

I was a big skeptic, when it comes to WordPress and the new Gutenberg editor, but combined with ACF + Timber its pure magic :) Looking forward to things to come!

Cheers
Alex

Enjoy coding …

Extended example:

 

The $collect array will hold all data, including all ACF fields. You will have full access to any field, including repeater fields. The $collect[‘main’] will just collect the standard post content.




Subscribe
Notify of
guest
20 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Vincent Morel
Vincent Morel
2 years ago

Just missing something here. Where do you find the block ID?

Vincent Morel
Vincent Morel
2 years ago
Reply to  Alex

Thanks! I understand. Seems last update broke “acf_setup_postdata”… We’ll need to find another way…

Vincent Morel
Vincent Morel
2 years ago
Reply to  Alex

Yes thanks! I juts find out! :)

Gabor Lippert
Gabor Lippert
2 years ago

You saved me from going crazy with this article. Thank you!!!

Carlos Eduardo
Carlos Eduardo
1 year ago

Great article Alex, helped me a lot!

I need to update a custom field inside a specific block. Do you know how update a field value inside that ‘acf_setup_meta’??

I tried using the ‘update_field’ function, but it saves the field on the post itself, not the block :(

Jake
Jake
11 months ago

Hi Alex

Thanks for taking a stab at this. Don’t know why this have to be this difficult.

I’m trying to grab a field within a repeater from another block, but still on the same page.

I’m simply trying to output the titles of each field in a repeater from a different block.

How do I do that?

Thanks SO much for any assistance you can throw my way.

Jake
Jake
10 months ago
Reply to  Alex

Wow, that would be amazing. Thanks Alex

Jake
Jake
10 months ago
Reply to  Alex

Hey Alex

Don’t mean to be pushy, but did you happen to figure out something? No worries if not.

Jake
Jake
10 months ago
Reply to  Alex

That’s very nice of you, thanks a lot.
Help a noob out, how do I make use of it?
Do I var_dump($collect) to output the array? If so, that just does array(0) { }

Chad
Chad
6 months ago

I understand how the basis of this works. I changed the parse_blocks to have my post info in it. BUT it is throwing an error on page:

Warning: key() expects parameter 1 to be array, null given

Any help would be appreciated.




Alexander

I am a full-stack developer. My expertise include:

  • Server, Network and Hosting Environments
  • Data Modeling / Import / Export
  • Business Logic
  • API Layer / Action layer / MVC
  • User Interfaces
  • User Experience
  • Understand what the customer and the business needs

 

I love programming,  design and know my way around server architecture as well.  I would never feel complete, with one of these missing.

I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.

Apart from that, I am a peace loving guy who tries to have people around him that think the same.  I truly believe in the principle: “If you help someone, someone will help you, when you need it."

Previous Next