I AM LISTENING TO
|
WAS ICH LIEBE
  • Englisch
  • Deutsch

Advanced Custom Fields – Free Your Gutenberg Blocks Data

10. Februar 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.




Abonnieren
Benachrichtige mich bei
guest
20 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Vincent Morel
Vincent Morel
2 Jahre zuvor

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

Vincent Morel
Vincent Morel
2 Jahre zuvor
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 Jahre zuvor
Reply to  Alex

Yes thanks! I juts find out! :)

Gabor Lippert
Gabor Lippert
2 Jahre zuvor

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

Carlos Eduardo
Carlos Eduardo
1 Jahr zuvor

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 Monate zuvor

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 Monate zuvor
Reply to  Alex

Wow, that would be amazing. Thanks Alex

Jake
Jake
10 Monate zuvor
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 Monate zuvor
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 Monate zuvor

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

Ich bin ein Full-Stack-Entwickler. Meine Expertise umfasst:

  • Server-, Netzwerk- und Hosting-Umgebungen
  • Datenmodellierung / Import / Export
  • Geschäftslogik
  • API Layer / Action Layer / MVC
  • Benutzeroberflächen
  • User Experience
  • Verständnis für Kundenwünsche und Geschäftsbedürfnisse

 

Ich liebe die Entwicklung, das Design und kenne mich auch mit Serverarchitekturen aus.  Ich würde mich nie vollständig fühlen, wenn einer der Bereiche fehlen würde.

Ich habe ein breites Interessengebiet, deshalb tauche ich ständig in neue Technologien ein und erweitere mein Wissen, wo immer es nötig ist. Die Technologien entwickeln sich schnell und ich genieße es, die neuesten Technologien zu nutzen.

Abgesehen davon bin ich ein friedliebender Kerl, der versucht, Leute um sich herum zu haben, die dasselbe denken.  Ich glaube wirklich an das Prinzip: "Wenn man jemandem hilft, wird einem jemand helfen, wenn man es braucht."

Previous Next