This really seems like it should work. Is it close?
The two fields are Date Picker fields. Both field have a value.
John,
I made this change, but am still not getting any results. I have one Event item that is set for the end of this year, so it should show up.
@nicmare I apologize. Completely my mistake on the formatting.
add_filter( 'render_block_core/post-title', function( $block_content, $block ) {
if(!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "duration") {
return sprintf("<div style='margin-bottom:%s'><strong>%s</strong></div>%s","10px",get_field("clip_duration"),$block_content);
} else if (!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "readAuthor") {
$author = get_field('author');
foreach( $author as $theAuthor ) {
$authorName = get_the_title( $theAuthor->ID );
}
return sprintf("<h4>Read / %s</h4>",$authorName,$block_content);
} else {
return $block_content;
}
}, 10, 2 );
@nicmare This worked great to get the contents of a text field output right after a title. But now I want to have multiple injections that show up in different places.
I modified your code to combine the items. It throws no errors, but when I used your code to output one item, then the other, separately, they worked. After combining them, it no longer works. I wonder if you or anyone else could help.
add_filter( 'render_block_core/post-title', function( $block_content, $block ) {
if(!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "duration") {
return sprintf("<div style='margin-bottom:%s'><strong>%s</strong></div>%s","10px",get_field("clip_duration"),$block_content);
} else if (!empty($block["attrs"]["className"]) && $block["attrs"]["className"] == "readAuthor") {
$author = get_field('author');
foreach( $author as $theAuthor ) {
$authorName = get_the_title( $theAuthor->ID );
}
return sprintf("<h4>Read / %s</h4>",$authorName,$block_content);
} else {
return $block_content;
}
}, 10, 2 );
[comment removed]
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.