echo '<span class="email">';
if ( get_post_meta($post->ID, "email", true) ) : echo 'Email: ', '<a href="mailto:'get_post_meta($post->ID, "email");'">' get_post_meta($post->ID, "email"); '</a>'; endif;
echo '</span>';
Thread Starter
Amy
(@amyn)
Whoops, can believe I forgot the “mailto:” in there. DOH!
But it is still giving me the same syntax error, overall:
unexpected T_STRING, expecting ‘,’ or ‘;’
Try:
echo '<span class="email">';
if ( get_post_meta($post->ID, "email", true) ) echo 'Email: ', '<a href="mailto:'get_post_meta($post->ID, "email");'">' get_post_meta($post->ID, "email"); '</a>'; echo '</span>';
Thread Starter
Amy
(@amyn)
That did not work either. π
Same error output again.
Your concatenation was all wrong:
echo '<span class="email">';
if ( get_post_meta($post->ID, "email", true) ) echo 'Email: <a href="mailto:' . get_post_meta($post->ID, "email") . '">' . get_post_meta($post->ID, "email") . '</a>';
echo '</span>'
Thread Starter
Amy
(@amyn)
Sorry for being a pain…I am trying every which way but still the last suggestion is still not working. Giving me this now:
unexpected T_ECHO, expecting ‘,’ or ‘;’
There’s a missing ; after echo '</span>'.
Thread Starter
Amy
(@amyn)
Thank you very much for your help esmi! Can’t believe I missed that. Must’ve been staring at it for too long.
When I corrected that, the page finally displayed but that code outputted:
“Email: Array”
I added in the “true” on all and it works perfect now. Here is my complete code now:
echo '<span class="email">';
if ( get_post_meta($post->ID, "email", true) ) echo 'Email: <a href="mailto:' . get_post_meta($post->ID, "email", true) . '">' . get_post_meta($post->ID, "email", true) . '</a>';
echo '</span>';
Thanks again!
Glad to hear that you got it working. π