Using an if exists statement with custom fields
-
I’m having trouble finding the proper wording/code to use a custom field if it exists.
What I have is an href that I’d like to link to a custom field by the name of “source_url”. But If that custom field doesn’t exist, I’d like to link to the_permalink.
So, if <?php get_post_meta($post->ID, ‘source_url’, true); ?> exists, echo that link, elseif echo <?php the_title(); ?>, in layman’s terms. ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Using an if exists statement with custom fields’ is closed to new replies.