Same here.
{
"apiVersion": 2,
"name": "acf/home-solutions",
"title": "Lösungen (Home)",
"description": "Der Lösungen Bereich - nur für die Startseite",
"category": "xxx",
"icon": "star-filled",
"keywords": ["home", "lösung"],
"acf": {
"mode": "edit",
"renderTemplate": "home-solutions.php"
},
"supports": {
"align": false
},
"style": ["file:./style/home-solutions.css"]
}
The edit mode shows preview and the toggle icon to edit.
Thank you! That helped me alot. Sometimes it can be so simple… ^^
Thanks for the feedback.
I’ve already tried it with a shortcode. Unfortunately, this is executed when I save the page in the backend. Very strange. So I thought you could easily solve this with ACF. 😀
🙄 Of course, I found the solution shortly after the post.
function example_block_category( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'example',
'title' => 'Example',
),
)
);
}
add_filter( 'block_categories', 'example_block_category', 10, 2);
I would use a style-editor.css
https://developer.wordpress.org/block-editor/developers/themes/theme-support/
OMG. You are my hero. This works fine and is exactly what I was looking for! Many thanks. Have been searching for a solution for days.
That seems to be exactly what I was looking for!
Can you explain what you mean with: {query_of_post_by_slug}?
Thank you for your answer but I think your solution does not help with my problem.
I expressed myself a bit awkwardly…sorry.
I have added a custom field to the file attachments (images) which can be filled out. (like the image alt attribute, description, title…)
The pictures are inserted in the text via the normal WYSIWYG editor. If the image has a description, I get it automatically (in the editor). Now I want the text of my custom field to be printed below the description (this should have an span around it or something).
I suspect I can only solve this via functions.php?
Yes. In my example it is a flexible content field .
Thanks for your answer. I’m searching for something like this:
$fieldname = field name of the marked the_sub_field('col_left');
<div class="<?php echo $fieldname; ?>">Blablabla</div>
Found it. With PHP 7.2. it doesnt work. With PHP 7.1.12 everything is fine.
The Answer:
I have put the Code inside the page loop and i have to change the code a little bit because the field type is checkbox…
<?php
$sidebars = get_field('sidebar');
if( $sidebars ):
?>
<?php foreach( $sidebars as $sidebar ): ?>
<?php dynamic_sidebar($sidebar); ?>
<?php endforeach; ?>
<?php endif; ?>
the checkbox field returned “value” but it doesnt work either…
Maybe because the snippet on page.php is outside the loop?
<div class="row">
<div class="col-lg-8 content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'page' );
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div>
<div class="col-lg-3 col-lg-offset-1">
<?php
$sidebar = get_field('sidebar');
dynamic_sidebar($sidebar);
?>
test
</div>
</div>
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.