John I just did as You told me. The situation is the same. As an output i get the same id for every image I attached. And it`s id of first attached image. I edit my old post and add another image and still get only id of first attached image
But John Your code works great. The problem is that it shows only custom-field-name from the first attached image. Under other attached images I get the same value but it suppose to change
Any ideas John ?
Thanks again. It is working… BUT it`s showing only custom-field-name of the first attached image under every image that I attached to this post.
What I mean:
1. First image
custom-field-name1
2. Second image
custom-field-name1
3. Third image
custom-field-name1
And it supposed to show:
1. First image
custom-field-name1
2. Second image
custom-field-name2
3. Third image
custom-field-name3
I hope I wrote it clearly 🙂
Im sorry John, but it does not work.
As an output under every image I get this code instead of custom-field-name
= get_attached_media(''); if () { foreach ( as ) { echo get_field('custom-field-name', ),'
'; } }
John… will You help me for the last time ? Im almost there 🙂
Ok so my last huge request is… I got this code that displays everything I want under every image attached to my post.
Here is the code:
<?php $block = 1;
$content = apply_filters('the_content', get_the_content());
$content = str_replace("/></a>", "/></a>
<div class='under-image'>
HERE I CAN PUT WHATEVER I WANT
</div> <br>
", $content);
$content = explode("</p>", $content);
for($i = 0; $i < count($content); $i++ ) {if ($i == $block) { ?>
<?php } echo $content[$i]. "";} ?>
How Can I combine the code with that one You gave me ?
Wow John. Its working. Thank You ! Im really glad that You wanted to help me. You re very kind:) If You ever will be in Poland write to me I will help You. I can send You lot of useful information about my country.
Ps. Lets say I will have couple of photos attached to one post. Is there is any chance that You could help me with that ?
OK. But like I was saying Im not a programmer, so please Can You help me with this ?
We`re so close John ! It showed me whole array of stuff.
For example: [ID] => 3281 – and its what Im looking for.
Now how to combine this code with the previous one ?
John in both cases I get nothing. Zero effect. It displays nothing
Im sorry but it just doesnt work
Can You please help me combine this code <?php echo get_field('my_custom_field', 3281); ?>
with this ? get_post_thumbnail_id();
I got attached only one picture to every post I made John, so I need to get the id the attachment.
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.