Display two custom values from a post

I’m using the following code to display a custom value. The custom value being ‘website’

<?php
  $custom_fields = get_post_custom($post_id); //Current post id
  $my_custom_field = $custom_fields['website']; //key name
  foreach ( $my_custom_field as $key => $value )
  echo $key . " => <a href='" . $value . "'>Click Here</a><br />";
?>

However, before the ‘Click here’ i’d like to include another custom value, thumb.

Read More

So the output would be:

Value of custom field thumb
Value of custom field website

Thanks.

Related posts

Leave a Reply

1 comment

  1. How about:

    $thumb = get_post_meta( $post_id, 'thumb', true );
    $url = get_post_meta( $post_id, 'website', true);
    echo "<a href='$url'><img src='$thumb' /></a>";
    

    The get_post_meta() function is ideal when you know ahead-of-time the names of the fields you want to retrieve. Setting the third parameter to true tells it that you want to return a single value, and not an array of values (it’s possible to set multiple values using the same meta key, and get an array of values back).