WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I'm trying to do is quite simple: I want to add a custom field named 'Button' to each post that will show a button (image) on the page with the value as its link.

It's basically a button that will show on every post, the link that the button points to will be entered in the value field of the custom field.

This is the code I used in single.php:

<div class="button">
  <a href="<?php get_post_meta($post->ID, 'Button', true); ?>">
    <img src="<?php echo get_template_directory_uri() . '/images/button.png'; ?>" alt="link" />

The problem is that the output of the value field doesn't appear. The link that supposed to be on the button image is not in place. Instead the button links to the post.

This is the website in question: http://digitalmediaboard.com

share|improve this question
up vote 1 down vote accepted

You need to echo get_post_meta(), like this:

<div class="button">
 <a href="<?php echo get_post_meta($post->ID, 'Button', true); ?>">
   <img src="<?php echo get_template_directory_uri() . '/images/button.png'; ?>" alt="link" />
share|improve this answer
Thanks for the answer! – George Grigorita Apr 10 '12 at 19:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.