fortkentgent
Member
Posted 1 year ago #
Hopefully somebody can assist me because I'm having no luck. I'm not an experienced coder but I'd really like to accomplish this. I want to link the title of my posts to external sources and I hope to use a conditional+custom field to do this. The custom field key is titled "source" and the value will be a url. So id like to say..
IF source (the key of my custom field)
url (the value of my custom field)
ELSE
<?php the_permalink() ?>
Could somebody please give me some help?
fortkentgent
Member
Posted 1 year ago #
fortkentgent
Member
Posted 1 year ago #
I got it.
<?php if (get_post_meta($post->ID, 'source', true) ) { ?>
<h1><a href="<?php echo get_post_meta($post->ID, "source", $single = true); ?>" rel="external" title="External Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php } else { ?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php } ?>
subiectiv
Member
Posted 10 months ago #
thanks man, i tried almost five days to make that thing work. of course, in some other circumstances, but it worked. you rule :)