Custom Sources with the WordPress Block Bindings API (yes, you can)

  Рет қаралды 556

Armando J. Perez-Carreno

Armando J. Perez-Carreno

Күн бұрын

Пікірлер: 10
@alvarogois
@alvarogois 6 ай бұрын
Great video. Thank you for showing some basic usage of this powerful feature. Just in time for a project I'm working, now I definitely have to try it!
@perezcarreno
@perezcarreno 6 ай бұрын
Thank you, Alvaro! I'm glad it helped! I find myself reaching for it more and more.
@jenniferp4137
@jenniferp4137 2 ай бұрын
In your final example at the end you return a string with html markup. I'm doing the same thing with a custom binding source callback but the output is not rendered as an element in the browser and it shows the markup and text. Has this been your experience as well? We have a number of fields that contain html markup so having this work would be wonderful. Otherwise, we'll be back to custom blocks and variations, sadly.
@jastos
@jastos 4 ай бұрын
Really interesting. How would this work with a block with context? For instance, I need a button inside of a query loop to link to the post url of the post. If I register_block_bindings_source, what would my $post object be? Can I get the individual values for the post inside of the query loop?
@perezcarreno
@perezcarreno 4 ай бұрын
That's a great question! The context will be whatever the loop is at the moment. Let's say you have a query loop, and you have a 'likes' block binding for instance. The 'likes' that appear will be for the each post within the query loop.
@jastos
@jastos 4 ай бұрын
@@perezcarreno Yes, this worked well for binding the post url to a button in the query block. I've found it annoying in the past that I couldn't use a button in the query block that linked to the post. I had to manually style the "Read More" link to look like a button. The next thing I want to figure out, is a good way to hide the block if the binding source is empty or returns a certain value. With a button, I can target an empty href, but how do you hide a if the binding is empty?
@perezcarreno
@perezcarreno 4 ай бұрын
@@jastos return an empty string in the block binding if you want it to disappear. Returning null shows the fallback text instead.
@jastos
@jastos 4 ай бұрын
@@perezcarreno Thanks again! It looks like for the button block, the text attribute determines whether the block is visible or not. So to bind the url, you need to bind the url & text. Looking forward to more development on this!
@lachieyoung1374
@lachieyoung1374 4 ай бұрын
Feels like shortcodes with extra steps lol
@perezcarreno
@perezcarreno 4 ай бұрын
Similar in the sense that you can write code to output content, but more powerful within the context of blocks because you can use all the native block settings in core blocks, while pulling in custom data.
Using Block Variations with the Block Bindings API
15:42
Brian Coords - WP Dev
Рет қаралды 2,1 М.
Connect to API's using WordPress, without writing code!
5:24
WPGetAPI
Рет қаралды 145 М.
Farmer narrowly escapes tiger attack
00:20
CTV News
Рет қаралды 12 МЛН
annio Tutorial: Partner-Login
12:24
annio
Рет қаралды 11
WordPress 6.6 is changing the game for Custom Fields
11:12
Brian Coords - WP Dev
Рет қаралды 10 М.
ACF Chat Friday - April 26, 2024: Block Bindings API
38:49
WP Engine Builders
Рет қаралды 769
The Interactivity API in Action, a conversation with Seth Rubenstein
42:55
Armando J. Perez-Carreno
Рет қаралды 302
Mistral Chat destroys the competition
6:15
Abdellah Codes
Рет қаралды 809
What Makes WordPress Blocks Great
20:09
Armando J. Perez-Carreno
Рет қаралды 35
How Hosting Choices Impact Website Speed: A Deep Dive with Bigscoots
1:31:03
Armando J. Perez-Carreno
Рет қаралды 59