I am using the Headway theme, and I need to add custom field code to page & posttitles. This is what I need to be able to do.

example http://www.marbiedesign.nl/_img/customfield.jpg [edit:image has been deleted]

The red button will be added through a custom field. It needs to be shown inline with the title. I have worked out I can do this using the headway_after_entry_title hook, but I can't seem to get the code right to retrieve the custom fields. I got this far :

//Add custom field image after entry title 
function title_btn() {
    echo '<div class="title-btn">[custom field code to go here]</div>';
add_action('headway_after_entry_title', 'title_btn');

and the outcome should be:

<a href="xxx"><img src="xxx"></a> 

where the xxx is the custom field url code

Hope anybody can help me out with this.

1 Answer 1


There's the get_post_meta() function to retrieve those data.

So basically, you'd write a function in your functions.php file (or in a custom plugin - take "Hello Dolly" as example) and hook it.

/* Plugin Name: (#66495) »kaiser« Headway Title Button */
function wpse66495_headway_title_button()
    return printf(
         '<div class="title-btn"><a href="%s" alt="%s"><img src="%s /></a></div>'
        ,get_post_meta( get_the_ID(), 'meta_key_link_url', true )
        ,get_post_meta( get_the_ID(), 'meta_key_thumb_url', true )
add_action( 'headway_after_entry_title', 'wpse66495_headway_title_button' );
  • how can I get my custom fields in here like this: <a href="customfield1"><img src="customfield2"></a> both customfields are urls
    – Marja
    Sep 28, 2012 at 11:36
  • See Update and read the code. You'll see where to enter those meta keys.
    – kaiser
    Sep 28, 2012 at 12:42
  • Thanks so much for this! would it be possible to edit this function so it won't show if the fields are empty? At the moment it takes up a lot of blank space.
    – Marja
    Sep 28, 2012 at 15:55
  • Check all the isset(), empty(), etc. stuff on php.net
    – kaiser
    Sep 28, 2012 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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