Home › Forums › Gutenberg › ACF Blocks – Need stable id › Reply To: ACF Blocks – Need stable id
Slightly modified
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "acf/clb-custom-info-card",
"title": "Info Card",
"description": "A custom info card block.",
"style": [ "clb_custom_info_card.css", "clb-custom-info-card-style" ],
"category": "common",
"icon": "admin-comments",
"keywords": ["testimonial", "quote"],
"acf": {
"mode": "preview",
"renderTemplate": "clb_custom_info_card.php"
},
"align": "full"
}
Save it as card-block.json
and place in theme subfolder /acf-blocks/
– or where you like. Just adjust paths.
Filename can be changed, but must end with -blocks.json
(discovered this after lots of debuging)
Style value can break the loading if the file can’t be found. It should be relative to the card-block.json
In your functions.php you can load it with
register_block_type(
get_template_directory() . '/acf-blocks/card-block.json'
);
I placed it in a subfolder to the theme /acf-blocks/
with clb_custom_info_card.css
in the same folder.
You can declare expected attributes with a static default value by adding this node in the json.
"attributes": {
"my_custom_attribute": {
"type": "string",
"default": "a_default_value"
}
}
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.