Custom field usage example (in Thesis function)

/ Published in: PHP
Save to your folder(s)

This shows how to add content (in this case a linked image) to the end of a post using WordPress custom fields and the Thesis theme.

Copy this code and paste it in your HTML
  1. function add_custom_field() {
  2. global $post;
  3. if (get_post_meta($post->ID, 'key', true)) { ?>
  4. <a href="<?php echo get_post_meta($post->ID, 'key', true); ?>"><img src="<?php echo get_post_meta($post->ID, 'key', true); ?>" alt="description" /></a>
  5. <?php }
  6. }
  7. add_action('thesis_hook_after_post', 'add_custom_field', 1);

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.