Dynamically adding Captions to images

Question

I have a site where the author has included Amazon Affiliate links. They’ve done this by adding the URL to product images.

I’m wondering if there’s a way to add a function that will automatically add a wp-caption below these images if they’re linked to Amazon.

Basically the condition would need to be: if an href containing an image is linked to a domain including ‘amazon’, add a caption below that image that says “Buy Now”. The caption would also have the same link as that image.

I’ve been able to do this with some hacky jQuery, but it doesn’t always fire properly. I think there might be a better way…

Thanks

0
, , David 2 years 2020-01-14T08:38:55-05:00 0 Answers 79 views 0

Leave an answer

Browse
Browse