Hello there,
I’d like to add a function to my child theme’s function.php file that adds the following content (an image wrapped in a link) to all posts with the “p.attachment” class. For reference this is where media posts and downloads from the plugin “Download Monitor” which I am using appear.
Here is the content I’d like to add after/underneath the image or download attachment:
<a href="https://google.com" target="_blank"><img src="image.png"></a>
I found this post which is trying to do something similar but to no avail in trying to make it work:
The PHP referenced from that post:
<?php
function filter_attachment_content($content) {
if(is_singular('attachment')){
$acf = get_field('fieldtitel');
}
return $content.$acf;
}
add_filter('the_content', 'filter_attachment_content');
Thanks in advance for any help I can receive on this!
Hey w3newbie,
Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
Basilis