Advanced (?) use of custom fields and if statements (second try)
-
My first thread here seems broken (two posts, but nothing is showing in the thread). I’ve sent a bug report and created this second thread.
To the question…
If i’ve entered a custom field with the name “audio_title” and value “thetitle” I can output the “thetitle” by doing:
<?php $key_name = get_post_custom_values($key = 'audio_title'); echo $key_name[0]; ?>
Now, IF I’ve also entered a custom field with the name “audio_source” and the value “http://domain.tld/source” i want the “thetitle” to be wrapped with an with audio_source value being the href like this:
<a href="$audio_source">$audio_title</a>
If there’s only an “audio_title” and no “audio_title” I just want the audio_title to be output without the surrounding<a></a>
.I’ve have zero php knowledge but someone led me to believe it’s possible using if statements and gave me this snippet:
if (!empty($key_name[0])) { echo "blarg" . $key_name[0] . "moreblarg"; }
Any help would be mostly appreciated.
- The topic ‘Advanced (?) use of custom fields and if statements (second try)’ is closed to new replies.