Hello acf community.
First of all excuse my english.
I’ve got a problem. I’m using the ACF linkfield (as array). Inside the linktext I use images/icons (inplmented by ). When I’m doing this the imgtag sometimes is rendered correctly and sometimes not. It’s seems just random if it works or not. I loaded some exmaples up.
I don’t use esc_html($link.. and tried things out like strip_tags – nothing works. I have to say, I’m not a php pro. Andyone has an idea what I can do?
<?php if( $button_buy ): $button_buy_url = $button_buy['url']; $button_buy_title = $button_buy['title']; $button_buy_target = $button_buy['target'] ? $button_buy['target'] : '_self'; ?> <a class="button button-buy" href="<?php echo esc_url( $button_buy_url ); ?>" target="<?php echo esc_attr( $button_buy_target ); ?>"><?php echo strip_tags($button_buy_title); ?></a> <?php endif; ?>
Hey John, hope this helps. This ist the code from the template. I’m using normal img tag inside the Linktext. Can you see it in the picture i loaded up? I blacked out the URL for reasons.
I don’t understand where you are getting the image from, is this entered into the link text? If it is something is transforming the html. I don’t know what that is.
try dumping the value and see if the HTML is altered before you add the link.
echo '<pre>'; var_dump($button_buy); echo '</pre>';
Hey John. Sorry for my bad explanations.
Yes. The image is postetd directly inside the linktext, see the picture i loaded up. I tested your script. The result you can also see in the uploaded images. The crazy about is, that sometimes it’s working and sometimes not. But I don’t want to waste your time too much. Otherwise I’ll find another soultion. Maybe I can add an acf imagefield and call it directly inside the linktag. So ->a,img,linktext,/a<- That would probably make more sense too.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.