Hello,
I created a Hook element to show additional information about prints and licensing of my photos on their attachment page. I also created a custom field that contains a link to an external site where a print can be purchased. Aaaaand (I’m quite proud of myself here;-) I managed to put these things together so that it does what I want – at least for those attachments which HAVE the custom field set… and not all of them do. :-/
Here’s my code in the Hook:
<p>
<?php
global $post;
$faa_url = get_post_meta( $post->ID, 'store_link', true );
printf( '<br>PRINTS: <a href=" %s " TARGET="_BLANK">purchase an open edition fine art print</a> of this photo, directly in my print-on-demand store.', $faa_url );
?>
</p>
<p>
LICENSING: To inquire about licensing this photo, please <a href="/contact/">contact me.</a>
</p>
Here’s an example where it looks like it should, where the custom field ‘store_link’ is set: https://www.alex-kunz.com/portfolio/black-white-portfolio-gallery/soul-sleeping/
But here’s an example where the custom field ‘store_link’ is NOT set: https://www.alex-kunz.com/portfolio/black-white-portfolio-gallery/hill-1948/
To resolve this, I’d like to make the output of my code conditional: if the custom field ‘store_link’ is not present or empty, output “text A”. If it’s set, output “text B”.
My problem is that when the custom field is not set, the variable $faa_url contains the attachment URL itself?! Or at least it seems that way to me…
I hope this isn’t too generic and/or trivial. Thanks!