I created a new block and added fields to it using ACF Pro.
acf_register_block([
'name' => 'incontent',
'title' => __('In-Content Teaser'),
'description' => __('Teaser Element mit Bild, volle Breite.'),
'render_template' => get_theme_file_path()."/resources/blocks/incontent.php",
'category' => 'layout',
'icon' => 'align-center',
'keywords' => ['teaser'],
]);
The block shows fine in the backend editor, I can change the content and everything. But it just doesn’t show up on the actual page. The data is there, but the output file doesn’t seem to be used.
Here is the output from the inspector:
wp:acf/incontent {
"id": "block_5d81fa6dbbf5a",
"name": "acf\/incontent",
"data": {
"bild": 303,
"_bild": "field_5d81fa0de504f",
"text": "Some text.]",
"_text": "field_5d81fa20e5050",
"link": {
"title": "Page",
"url": "https:\/\/dev.url.de\/page\/",
"target": ""
},
"_link": "field_5d81fa38e5051"
},
"align": "",
"mode": "preview"
} /
This is my render file:
<?php
/**
* Block Name: In-Content Teaser
*/
print('die');
die();
$bild = wp_get_attachment_image(get_field('bild'), 'large', '', ["alt" => ""]);
$text = get_field('text');
$link = get_field('link');
?>
<div class="gutenberg-incontent">
<?php echo $bild; ?>
<a href="<?php echo $link['url']; ?>">
<?php echo $text; ?>
</a>
</div>
Note that the print and die are for my debbugging right now. Those statements do get executed when editing the page in the backend, but not when looking at the page in the frontend. However, checking with file_exists shows that the code can find my render file in both cases.
Any idea why it’s not being executed?
I’m suddenly having the same issue after it working fine before. Do you know what was causing this for you?
Did you find a fix for this? There’s literally no answers anywhere on why it is happening 🙁
Same Problem.. suddenly blocks only rendered in frontend when im logged in as wordpress user? wtf
Can someone please who has the answer to this please share. This is super annoying when this is not working on the frontend.
You must be logged in to reply to this topic.
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.