Having the same problem. Image shows perfectly on every page except on tag.php, category.php and archive.php.
<?php $logo = get_field('logo', 'option'); ?>
<img id="logo" src="<?php echo $logo['url'];?>" alt="<?php echo $logo['alt']; ?>" title="<?php echo $logo['title']; ?>" />
Hi, thanks so much for this. Helped a lot! But I need some help here, please.
I want my title to have not only the ACF field value, but also the custom taxonomy I’ve created called “pico”. When I run this code,
function my_acf_update_value( $value, $post_id, $field ) {
$terms = wp_get_post_terms($post_id, 'pico');
$pico = false;
foreach($terms as $term)
{
if($term->parent)
{
$parent = get_term($term->parent, 'pico');
$pico = $term->name;
break;
}
}
//Default to first selected term name if no children were found
$pico = $pico ? $pico : $terms[0]->name;
$new_title = $pico . ' - ' . $value;
$new_slug = sanitize_title( $new_title );
// Update post
$my_post = array(
'ID' => $post_id,
'post_title' => $new_title,
'post_name' => $new_slug,
);
// Update the post into the database
wp_update_post( $my_post );
return $value;
}
add_filter('acf/update_value/name=data_do_boletim', 'my_acf_update_value', 10, 3);
it gives me these error messages:
Notice: Undefined offset: 0 in /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php on line 219
Notice: Trying to get property of non-object in /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php on line 219
Warning: Cannot modify header information – headers already sent by (output started at /Users/Mauricio/Sites/RicoSurf/wp-content/themes/ricosurf/functions.php:219) in /Users/Mauricio/Sites/RicoSurf/wp-includes/pluggable.php on line 1196
But when I go back and see that post, the title is perfect, exactly the way I want.
So I assume the code “is working” just not 100%. Can some one help me find out what’s wrong?
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.