single.php | how to insert custom field data into a URL
-
I’m learning to play around with custom fields and now I’m trying to take the data from a custom field and add it to a URL.
Here’s the code I’m using right now
if ( get_post_meta($post->ID, 'amazon', true) ) : { echo '<a class="abutton medium orange" href="">Kindle</a>'; }
This will successfully show what I want but of course links to nothing.
I’ve also tried a lot of other methods I found online but nothing seems to work.In short, I want the link to look like this
href="$amazon"
where $amazon is the name of my custom field.
Any suggestions on how I could go about coding that withing my single.php file?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘single.php | how to insert custom field data into a URL’ is closed to new replies.