Block Binding API – Add prefix text with the binding value
-
I have been testing Block binding and it’s great!
Is there a way to add static text before or after the binding value?For example, I have a CPT called “Books” and a ‘ISBN’ custom field.
I have added a value to the ‘ISBN’ custom field and added the block binding code to the block editor.<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"acf/field","args":{"key":"book_isbn"}}}}} --> <p>The value of this paragraph comes from a block binding and will be replaced at render.</p> <!-- /wp:paragraph -->
It’s working and it’s displaying the number on the front-end, but I want to display this label text ‘ISBN:’ before the binding value like this:
ISBN: 123456789
Is there a way to do that without have to add an extra paragraph block (that has the ‘ISBN:’ text)?
I want the binding value and static text to show if the ‘ISBN’ custom field is not empty. If there isn’t, then it will not show anything (no an empty paragraph ).
Thank you!
- The topic ‘Block Binding API – Add prefix text with the binding value’ is closed to new replies.